Fixed #18233: Raise IOError if destination file already exists, in django.core.files.move.file_move_safe. #18

wants to merge 2 commits into


None yet

4 participants


On certain platforms like Linux, the existing code will simply ignore allow_overwrite and go ahead and overwrite the destination file anyway. This fixes it.

ps. This is also my first contribution to Django :)


Great work with the individual commit with tests !

@jezdez jezdez commented on the diff May 3, 2012
@@ -51,6 +51,8 @@ def file_move_safe(old_file_name, new_file_name, chunk_size = 1024*64, allow_ove
+ if not allow_overwrite and os.path.exists(new_file_name):
+ raise IOError('Destination file already exists: \'{0}\''.format(new_file_name))
jezdez May 3, 2012 Django member

It's best practice to use common string substitution.

Django member

I am closing this pull request as the ticket discussions indicate this isn't 100% ready for commit.

@akaariai akaariai closed this Jul 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment