Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop in directory discovery #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jul 17, 2023

  1. Fix infinite loop in directory discovery

    The `fix_storage` method enters an infinite loop when there are other
    directories that have `root_path` as prefix.
    
    For example, if the contents of the bucket look like this:
    ```
    gs://mybucket/abc/file.txt
    gs://mybucket/abc123/file.txt
    ```
    
    this code results in an infinite loop:
    ```python
    from fs import open_fs
    open_fs("gs://mybucket/abc?strict=False").fix_storage()
    ```
    
    In order to avoid this, we need to ensure `root_path` has a trailing
    "/", when listing blobs, which prevents "abc123/file.txt" from being
    listed as child of "abc".
    
    Additionally, `Bucket.list_blobs` was deprecated in favor of
    `Client.list_blobs` (see [reference documentation][1]).
    
    [1]: https://cloud.google.com/python/docs/reference/storage/1.44.0/buckets#listblobsmaxresultsnone-pagetokennone-prefixnone-delimiternone-startoffsetnone-endoffsetnone-includetrailingdelimiternone-versionsnone-projectionnoacl-fieldsnone-clientnone-timeout60-retrygoogleapicoreretryretry-object
    manuteleco committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    1809e10 View commit details
    Browse the repository at this point in the history