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

collectstatic -c fails since django 1.9 for s3 storage #112

Closed
xblitz opened this issue Jan 17, 2016 · 1 comment
Closed

collectstatic -c fails since django 1.9 for s3 storage #112

xblitz opened this issue Jan 17, 2016 · 1 comment
Labels

Comments

@xblitz
Copy link

xblitz commented Jan 17, 2016

it seems that since django 1.9 specificaly this PR django/django@87d7824 it breaks the "collectstatic -c" since it tries to validate that the root directory exists (which is empty in out case) because the bucket.new_key fails if the key name is empty

In the case of django-storages, maybe we can check if the bucket exists or just return true if its empty? (I think I would go for the true if empty)

Here is the Traceback:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
    collected = self.collect()
  File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 89, in collect
    self.clear_dir('')
  File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 210, in clear_dir
    if not self.storage.exists(path):
  File "/app/.heroku/python/lib/python3.4/site-packages/storages/backends/s3boto.py", line 433, in exists
    k = self.bucket.new_key(self._encode_name(name))
  File "/app/.heroku/python/lib/python3.4/site-packages/boto/s3/bucket.py", line 622, in new_key
    raise ValueError('Empty key names are not allowed')
ValueError: Empty key names are not allowed
@jschneier
Copy link
Owner

Thanks for the report. I'm torn between the 2 possible fixes. From a strictly correctness standpoint I think that checking for bucket existence makes more sense. The only time that doesn't matter in this case is when you have set the setting AWS_AUTO_CREATE_BUCKET.

Side note: looks like we should be using get_key for checking existence.

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

No branches or pull requests

3 participants