If the destination file exists and ``allow_overwrite`` is ``False``,
this
function will throw an ``IOError``.
However, if the destination file exists and movement is performed using
os.rename (which is the case most of the times) then no exception is being
thrown. The exception is only being thrown if streaming manually from one
file to another.
This could be fixed by doing one of the following:
1. update the docstring to match the actual behavior
2. make the function raise IOError regardless of how the movement is being
performed
--
Ticket URL: <https://code.djangoproject.com/ticket/20486>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* version: 1.4 => master
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:1>
Comment (by kux):
Note. This might be platform dependent.
I reproduced this on Linux 3.2.0-23-generic-pae #36-Ubuntu SMP
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:2>
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Looking over the code and
http://docs.python.org/2/library/os.html#os.rename it looks like this is
quite true.
An interesting note is os.rename will not replace the file on Windows: "On
Windows, if dst already exists, OSError will be raised even if it is a
file; there may be no way to implement an atomic rename when dst names an
existing file." So this seems to be unix systems only.
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:3>
* owner: nobody => Kamu
* status: new => assigned
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
Comment:
I had a stab at fixing it. Please see:
https://github.com/django/django/pull/1253
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:4>
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:5>
* cc: Kamu (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"18e79f1425fa87f2f38df25c65203ec4d311f499"]:
{{{
#!CommitTicketReference repository=""
revision="18e79f1425fa87f2f38df25c65203ec4d311f499"
Fixed #20486 -- Ensure that file_move_safe raises an error if the
destination already exists.
Thanks to kux for the report, and Russ Webber for the patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20486#comment:7>