GNOME Bugzilla – Bug 168287
Rename file in archive can overwrite other existing files
Last modified: 2005-04-15 17:20:53 UTC
Please describe the problem: When renaming a file or a folder to a new name the rename operation will overwrite any other file or folder having the same name as the new name. E.g. if there is an archive with two file in it called "1" and "2" if I rename "2" to "1" then "1" will be deleted and "2" renamed as "1". Steps to reproduce: 1. 2. 3. Actual results: Expected results: A warning dialog should be displayed offering the user the decision to overwrite or not. Does this happen every time? Other information:
Here's a patch that should solve it - breaks the string freeze, so probably can't go in until post 2.10.
Created attachment 38074 [details] [review] prompt on overwrite during renames
Surely that string can be copied in from somewhere else? it or something basically identical must exist elsewhere...
The strings in question are - _("The file already exists. Do you want to overwrite it?") _("Overwrite") while _("Overwrite") already exists in the translations, the only things close to the other are - _("The archive already exists. Do you want to overwrite it?") _("The archive is already present. Do you want to overwrite it?") [note, that's probably another bug that needs to be fixed ;)] which don't seem to be appropriate.
I was thinking nautilus or something like that...
i only bring it up because this sure looks like data loss to me.
Hrm, nautilus has - #: libnautilus-private/nautilus-file-operations.c:1094 #, c-format msgid "The file \"%s\" already exists. Would you like to replace it?" but I have no clue how I'd merge all the translations from another module. Also just recently thought the patch might not be complete - it checks for the existance of another file of the same name, but really if the relative path is different there is no problem. Will test this out and update the patch if necessary.
Maybe christian can help :)
Created attachment 38075 [details] [review] Updated patch
Here's an updated patch so that it doesn't prompt if there is a file of the same filename in a different directory. However, I couldn't for the life of me figure out how best to make the behavior apply to directories, as those don't seem to be stored in the FileData struct. Paolo, you might have to help me with this one ;) To reproduce, rename a directory in an archive to the same name as an already existing directory. It just overwrites without prompting, darnit.
Created attachment 38078 [details] [review] New version of the patch.
Okay, another patch that seems to sort out the directories as well, although not so happy with this approach - is this the only way? Also introduces another new string. Interestingly, renaming a directory, doesn't seem to unlink the old one if it's empty, so you end up getting empty directories on extraction. Is this desired behavior?
Now free from string freeze.
fixed in cvs now.