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

Blob not found when iterating over container containing blobs in subfolders #80

Open
snorrea opened this issue Mar 15, 2021 · 0 comments

Comments

@snorrea
Copy link

snorrea commented Mar 15, 2021

The following fails:

from cloudstorage.drivers.local import LocalDriver

storage = LocalDriver(key="./foobar/")
storage.create_container("foo")
container = storage.get_container("foo")
container.upload_blob("./todo.md", blob_name=f"12/1231/todo.md")
for b in container:
    print(b.path, b.name)

With the following trace:

FileNotFoundError                         Traceback (most recent call last)
~/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cloudstorage/drivers/local.py in _make_blob(self, container, object_name)
    358         try:
--> 359             stat = os.stat(str(object_path))
    360         except FileNotFoundError:

FileNotFoundError: [Errno 2] No such file or directory: 'foobar/foo/todo.md'

During handling of the above exception, another exception occurred:

NotFoundError                             Traceback (most recent call last)
<ipython-input-11-cae0a547d03a> in <module>
      5 container = storage.get_container("foo")
      6 container.upload_blob("./todo.md", blob_name=f"12/1231/todo.md")
----> 7 for b in container:
      8     print(b.path, b.name)

~/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cloudstorage/drivers/local.py in get_blobs(self, container)
    551                     continue
    552                 object_name = pathlib.Path(full_path).name
--> 553                 yield self._make_blob(container, object_name)
    554 
    555     def download_blob(self, blob: Blob, destination: FileLike) -> None:

~/.pyenv/versions/3.8.2/lib/python3.8/site-packages/cloudstorage/drivers/local.py in _make_blob(self, container, object_name)
    359             stat = os.stat(str(object_path))
    360         except FileNotFoundError:
--> 361             raise NotFoundError(messages.BLOB_NOT_FOUND % (object_name, container.name))
    362 
    363         meta_data = {}

NotFoundError: Blob 'todo.md' not found in container 'foo'.

Is this expected behaviour? The file is created in subfolders as expected...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant