django-watchman
django-watchman copied to clipboard
Make WATCHMAN_STORAGE_PATH relative to Django's default storage
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)
Coverage remained the same at 90.975% when pulling bfa3583ee2a6d2b8c0eabffc3cbd96c9effe8f5e on pchiquet:fix-storage-path into ab95718efa9d71cd2611f14a0cf9685ad8dfda11 on mwarkentin:master.
Coverage remained the same at 90.975% when pulling bfa3583ee2a6d2b8c0eabffc3cbd96c9effe8f5e on pchiquet:fix-storage-path into ab95718efa9d71cd2611f14a0cf9685ad8dfda11 on mwarkentin:master.
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.