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

Make WATCHMAN_STORAGE_PATH relative to Django's default storage #156

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pchiquet
Copy link

@pchiquet pchiquet commented Apr 9, 2020

Before this change, watchman may use an invalid path when the default storage does not use MEDIA_ROOT.

For example :

  • MEDIA_ROOT is set to "/media"
  • the default storage is Amazon S3 (or another custom storage)

then, watchman tries to write to "/media/watchman-xx-xx.txt", which fails with :

ValueError: the joined path is located outside of the base path component
  File "storages/backends/s3boto3.py", line 377, in _normalize_name
    return safe_join(self.location, name)
  File "storages/utils.py", line 79, in safe_join
    raise ValueError('the joined path is located outside of the base path'
SuspiciousOperation: Attempted access to '/media/django-watchman-730f4aa9-3d7d-4931-9993-5e13b422afa3.txt' denied.
  File "watchman/decorators.py", line 28, in wrapped
  File "watchman/checks.py", line 63, in _check_storage
  File "django/core/files/storage.py", line 51, in save
    name = self.get_available_name(name, max_length=max_length)
  File "storages/backends/s3boto3.py", line 582, in get_available_name
    return super(S3Boto3Storage, self).get_available_name(name, max_length)
  File "django/core/files/storage.py", line 75, in get_available_name
    while self.exists(name) or (max_length and len(name) > max_length):
  File "storages/backends/s3boto3.py", line 474, in exists
    name = self._normalize_name(self._clean_name(name))
  File "storages/backends/s3boto3.py", line 380, in _normalize_name
    name)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 90.975% when pulling bfa3583 on pchiquet:fix-storage-path into ab95718 on mwarkentin:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 90.975% when pulling bfa3583 on pchiquet:fix-storage-path into ab95718 on mwarkentin:master.

@stale
Copy link

stale bot commented Jun 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 9, 2020
@stale stale bot removed the stale label Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants