Opened 15 years ago
Closed 11 years ago
#13518 closed New feature (fixed)
Add settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | File uploads/storage | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Hi.
In core/files/storage.py, FILE_UPLOAD_PERMISSIONS is used to set the permissions of created files. It also makes the containing directory if it doesn't exist, but doesn't set the permissions for this directory. One possible patch is attached.
I can imagine cases where one would want the directory permissions to be different from file permissions. I'm not sure how objectional new setting names are.
Thanks.
Attachments (1)
Change History (9)
by , 15 years ago
Attachment: | storage_perms.patch added |
---|
comment:1 by , 15 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:5 by , 12 years ago
The lack of this feature hit me a few days ago, so I've worked up a fix, taking into account the given suggestions.
The commit in question:
https://github.com/Raumkraut/django/commit/1c0fe5d1c09bb3210812e32b88577c4572520f40
Since this is my first Django commit, and the ticket is somewhat old, there are some things I'm not certain are "correct":
- The documentation sections I've added defer explanation of the intricacies of file permissions to the existing FILE_UPLOAD_PERMISSIONS entries, in preference to duplicating the information.
- Since os.makedirs accounts for the system umask, and os.chmod doesn't, I've added code to temporarily zero out the umask while the directories are created. The intent is to maintain consistency of behaviour between the two settings.
Are these acceptable implementations, or do I need to tweak further before I send out a pull request?
comment:6 by , 12 years ago
I've gone ahead and created a pull request with my patch: https://github.com/django/django/pull/1225
Hopefully someone can take a look at it?
comment:7 by , 11 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Summary: | FILE_UPLOAD_PERMISSIONS used for created files, but not created directories → Add settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS |
Comments on PR.
comment:8 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Good suggestion, but:
As for introducing a new FILE_UPLOAD_DIRECTORY_PERMISSIONS setting; while we generally try to avoid introducing new settings, in this case it makes sense to me. However, this also means extra documentation for point (3).