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

listdir returns empty list on Azure storage if no trailing slash on directory path #1270

Open
maribedran opened this issue Aug 2, 2023 · 0 comments

Comments

@maribedran
Copy link

I ran into an issue trying to list files from a directory that only happens with Azure storage. The code below works both with FileSystemStorage and S3Boto3Storage, but on Azure the files list is empty. It's only able to list the files when I add a trailing slash to the directory _, old_files = default_storage.listdir(f"{RecordsDownloader.DOWNLOAD_DIR}/").

_, old_files = default_storage.listdir(RecordsDownloader.DOWNLOAD_DIR)
for name in old_files:
    path = f"{RecordsDownloader.DOWNLOAD_DIR}/{name}"
    default_storage.delete(path)
azure-common==1.1.27
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
boto3==1.23.5
botocore==1.26.5
Django==3.2.3
django-storages==1.11.1
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