Wrong filename when restoring from Trash

Bug #974208 reported by Alexis de Lattre on 2012-04-05
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Nautilus
Fix Released
Medium
One Hundred Papercuts
Medium
Timothy Arceri
nautilus (Ubuntu)
Low
Unassigned

Bug Description

In this particular scenario, the filename is wrong when restoring a file from Trash. Here is the exact scenario, that I am able to reproduce 100% of the time on Ubuntu 12.04 and 10.04 (it probably affects all Ubuntu versions) :

1. Put 2 files (their content can be identical or different) with the same name in 2 different directories :
mkdir ~/test1
mkdir ~/test2
cp installation_manual.pdf test1/doc.pdf
cp report.pdf test2/doc.pdf

2. Open Nautilus ; go to the "test1" directory and delete the file "doc.pdf". Go to the "test2" directory and delete the file "doc.pdf".

3. In the Trash directory, you now have :
% ls -l ~/.local/share/Trash/files/
total 19M
-rw-r--r-- 1 alexis alexis 758K avril 5 14:29 doc.2.pdf
-rw-r--r-- 1 alexis alexis 18M avril 5 14:29 doc.pdf

% ls -l ~/.local/share/Trash/info
total 8,0K
-rw-rw-r-- 1 alexis alexis 82 avril 5 14:30 doc.2.pdf.trashinfo
-rw-rw-r-- 1 alexis alexis 82 avril 5 14:30 doc.pdf.trashinfo

% cat ~/.local/share/Trash/info/doc.pdf.trashinfo
[Trash Info]
Path=/home/alexis/test1/doc.pdf
DeletionDate=2012-04-05T14:30:02

% cat ~/.local/share/Trash/info/doc.2.pdf.trashinfo
[Trash Info]
Path=/home/alexis/test2/doc.pdf
DeletionDate=2012-04-05T14:30:07

As you can see, the file "doc.pdf" from the "test2" directory is renamed "doc.2.pdf" in the Trash directory, but it's related "trashinfo" file has the right filename "doc.pdf" in the "Path" variable.

4. In Nautilus, go to the Trash, select the 2 files and clic on "Restore".

5. Now look at the names of the restored files :

% ls -l ~/test1/
total 18M
-rw-r--r-- 1 alexis alexis 18M avril 5 14:29 doc.pdf

% ls -l ~/test2/
total 760K
-rw-r--r-- 1 alexis alexis 758K avril 5 14:29 doc.2.pdf

As you can see, the file restored in the "test2" directory has a filename "doc.2.pdf" instead of "doc.pdf".

This bug should certainly be reported upstream, but I don't know which software component is responsible for this problem ; if someone tells me which software component is responsible, I can take the time to report the bug upstream.

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/974208/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Fabio Marconi (fabiomarconi) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. This bug did not have a package associated with it, which is important for ensuring that it gets looked at by the proper developers. You can learn more about finding the right package at https://wiki.ubuntu.com/Bugs/FindRightPackage . I have classified this bug as a bug in nautilus.

When reporting bugs in the future please use apport by using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https://help.ubuntu.com/community/ReportingBugs.

affects: ubuntu → nautilus (Ubuntu)
Changed in nautilus (Ubuntu):
status: New → Confirmed
Changed in nautilus (Ubuntu):
importance: Undecided → Low
status: Confirmed → Triaged
Changed in nautilus:
importance: Unknown → Medium
status: Unknown → New
Changed in hundredpapercuts:
milestone: none → raring-round-2
status: New → Triaged
assignee: nobody → Papercuts Ninja (papercuts-ninja)
Timothy Arceri (t-fridey) wrote :

To help kickstart anyone who wants to work on this one. The code is in libnautilus-private/nautilius-file-utilities.c
the function nautilus_restore_files_from_trash()

It would seem that the file being moved back to its original location has not been given its original name which is stored in the .trashinfo file. Shouldn't be to difficult to fix this one.

Changed in hundredpapercuts:
importance: Undecided → Medium
Timothy Arceri (t-fridey) wrote :

One further tip you can look at the code here: http://git.gnome.org/browse/gvfs/tree/daemon/trashlib/trashitem.c#n137
For an example of how to read the .trashinfo file.

Timothy Arceri (t-fridey) wrote :

I've looked into this one a little more.

The problem is with the code in libnautilus-private/nautilius-file-utilities.c
the function nautilus_restore_files_from_trash()
uses nautilus_file_operations_move()

This moves the files from the trash directory back to the path stored in Trash
Info by passing a destination directory. The problem is there is no destination
filenames given so they end up with the filename used when they were in the
trash directory rather than the original filename.

Changed in hundredpapercuts:
assignee: Paper Cuts Ninja (papercuts-ninja) → Timothy Arceri (t-fridey)
status: Triaged → In Progress
Timothy Arceri (t-fridey) wrote :

I've submitted a patch that fixes the bug upstream however it is currently throwing a warning that needs to be cleaned up.

Timothy Arceri (t-fridey) wrote :

The warning seems to be limited to 3.4. The code has changed in 3.6 and the warning is no longer an issue. Hopefully the upstream patch will get a review soon.

Changed in hundredpapercuts:
milestone: none → raring-ee
Changed in hundredpapercuts:
milestone: raring-ee → papercuts-nautilus
Changed in hundredpapercuts:
status: In Progress → Fix Committed
Changed in nautilus (Ubuntu):
status: Triaged → Fix Committed
Changed in nautilus:
status: New → Fix Released
Jeremy Bicha (jbicha) wrote :

Let's not mark this fix committed for Ubuntu since the fix is not in Ubuntu nor is it in the packaging branch.

Changed in nautilus (Ubuntu):
status: Fix Committed → Triaged
Sebastien Bacher (seb128) wrote :

the fix is in git: http://git.gnome.org/browse/nautilus/commit/?id=ecee8be850b8342c804de2ecc3e613b99a20a010 ... setting as "fix commited" because it makes easier to spot available patches we can backport in the bug list

Changed in nautilus (Ubuntu):
status: Triaged → Fix Committed
Timothy Arceri (t-fridey) wrote :

Thanks Sebastien, I was pretty sure I had done the right thing marking as Fix Commited. Thanks for clearing this up.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nautilus - 1:3.6.3-0ubuntu3

---------------
nautilus (1:3.6.3-0ubuntu3) raring; urgency=low

  * debian/patches/git_restore_filename.patch: use the correct filename when
    restoring files, thanks Timothy Arceri (lp: #974208)
  * debian/patches/git_launcher_no_frame.patch: "don't add a thumbnail
    border around desktop file launchers" (lp: #1085320)
 -- Sebastien Bacher <email address hidden> Mon, 03 Dec 2012 16:17:24 +0100

Changed in nautilus (Ubuntu):
status: Fix Committed → Fix Released
Changed in hundredpapercuts:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.