#8203: File Storage can't delete temporary uploaded files in Windows
-------------------------------------------+--------------------------------
Reporter: julien | Owner: nobody
Status: new | Milestone: 1.0
Component: File uploads/storage | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by snaury):
What I find strange is that NamedTemporaryFile is supposed to delete the
file upon closing. :-/ So if you close it before you move it there should
be nothing to move. :-/ Yet the patch works. ''*some time later*'' Ah! So,
you redefine NamedTemporaryFile on nt in django.core.files.temp, no
surprise it works so strangely. What I *must* stress then is that on non-
nt systems tempfile.NamedTemporaryFile will destroy the file upon closing
and there would be nothing to move: this patch effectively moves this bug
to all the other platforms.
My solution would be to rework django.core.files.move to never rely on
shutil.move: it is impossible to know where exactly it failed, it could
have race condition with allow_overwrite=False (if after the check the
file suddenly materialized then shutil.move will overwrite it). And more
importantly, if shutil.move failed then all the code below doesn't make
sense: it will fail as well.
Can't prepare the patch right now, but it would be pretty simple: use
os.rename only, don't use os.O_CREAT when allow_overwrite and catch
OSError around os.remove.
--
Ticket URL: <http://code.djangoproject.com/ticket/8203#comment:12>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---