filebrowser-safe icon indicating copy to clipboard operation
filebrowser-safe copied to clipboard

Recent commit to S3BotoStorageMixin forces use of preload_metadata

Open paulcwatts opened this issue 10 years ago • 4 comments

The commit https://github.com/stephenmcd/filebrowser-safe/commit/8d91c77225ec9bbb4672e2bcd9e5d8b34ffd3a98 seems to have an unintended consequence. The entries dictionary is only populated if preload_metadata = True (https://bitbucket.org/david/django-storages/src/f153a70ba254dc129d9403546809a02256ef75b5/storages/backends/s3boto.py?at=default#s3boto.py-302)

If preload_metadata = False (which is the default) then this causes a KeyError when there is anything in the bucket.

It seems instead that this should call self.size rather than using self.entries directly. self.size(name) does everything the recent change does but without requiring preload_metadata = True.

paulcwatts avatar Aug 01 '15 22:08 paulcwatts

I'm not across any of this at all unfortunately, but if you have a fix in mind, it's certainly welcome!

stephenmcd avatar Aug 02 '15 03:08 stephenmcd

I've recently deployed a Mezzanine project using AWS and got the same problem, KeyError due to empty entries if the preload_metadata option is disabled (default value). The solution has been perfectly explained by the author of the issue.

moiseshiraldo avatar Feb 12 '16 00:02 moiseshiraldo

This cost me about 8 hours by the way, i couldn't for the life of me figure out why this was failing.

derek-adair avatar Mar 11 '16 23:03 derek-adair

I'm glad this issue could help at least. I'd submit a PR, but I'm no longer using Mezzanine for any active projects.

paulcwatts avatar Mar 11 '16 23:03 paulcwatts