#8455 closed (fixed)
Lack of filesystem permissions to save uploaded file results in server hang
Reported by: | Carl Meyer | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If the web server user does not have filesystem permissions to write to the "upload_to" directory of a FileField or ImageField, attempting to upload a file results in the server process hanging and eating 100% CPU.
Instead, there should be a 500 error or debug page with a sensible error message.
This issue seems to exist ever since file-storage-refactor. I can replicate it on both the Django development server and Apache 2.2 on Debian Linux.
I believe the problem is that django.core.file.storage.FileSystemStorage._save() makes unwarranted assumptions about the reason for an OSError, causing an infinite loop, as outlined by rajeshdhawan in this comment on #8203.
Attachments (3)
Change History (8)
by , 16 years ago
Attachment: | issue-8455.diff added |
---|
comment:1 by , 16 years ago
Has patch: | set |
---|
Don't know if this is the best way to go about it, but this patch resolves the issue for me. It should also fix the problem for any other potential error condition (out of disk space, whatever) that could result in an OSError.
comment:2 by , 16 years ago
In particular, I should note that I have no idea whether the error number checked by my patch is cross-platform or not (I've only tested on Linux). If there aren't reliable cross-platform error numbers, a good patch might need to entirely rework the logic (do an explicit test for the existence of the file and not catch OSError at all?).
by , 16 years ago
Attachment: | issue-8455.errno.diff added |
---|
better patch, uses os.errno.EEXISTS instead of raw error number
by , 16 years ago
Attachment: | issue-8455.errno2.diff added |
---|
os.errno is Python 2.5 only, use top-level errno instead
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
patch to check OSError error number