restore-trash crashes if the original path does not exist (even if it's in the same trash can)

Bug #310088 reported by Don Cristóbal
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
trash-cli (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: trash-cli

1) Ubuntu 8.10, all updates applied (2008-12-20)

2) trash-cli:
  Installed: 0.10.r55-0ubuntu1
  Candidate: 0.10.r55-0ubuntu1
  Version table:
 *** 0.10.r55-0ubuntu1 0
        500 http://ch.archive.ubuntu.com intrepid/universe Packages
        100 /var/lib/dpkg/status

3) What I did:
- trashed all files from a directory
- trashed the directory itself
- tried to restore-trash a file from the directory

What happened (from the terminal):
===
$ restore-trash
(...)
  51 2008-12-20 22:46:13 /media/EXTERN/_lagaffe bis 070907/000-132.jpg
  52 2008-12-20 22:46:13 /media/EXTERN/_lagaffe bis 070907/000-133.jpg
  53 2008-12-20 22:46:13 /media/EXTERN/_lagaffe bis 070907/goodies_gaston.gif
  54 2008-12-20 22:46:37 /media/EXTERN/_lagaffe bis 070907
What file to restore [0..54]: 51
Traceback (most recent call last):
  File "/usr/bin/restore-trash", line 39, in <module>
    list[index].restore()
  File "/var/lib/python-support/python2.5/libtrash/__init__.py", line 418, in restore
    self.original_file.move(self.path)
  File "/var/lib/python-support/python2.5/libtrash/__init__.py", line 67, in move
    return shutil.move(self.path, str(dest))
  File "/usr/lib/python2.5/shutil.py", line 205, in move
    copy2(src,dst)
  File "/usr/lib/python2.5/shutil.py", line 96, in copy2
    copyfile(src, dst)
  File "/usr/lib/python2.5/shutil.py", line 52, in copyfile
    fdst = open(dst, 'wb')
IOError: [Errno 2] No such file or directory: '/media/EXTERN/_lagaffe bis 070907/000-132.jpg'
===

4) What I expected to happen:
restore-trash should:
a) automatically restore/create the original directory where the file used to live (acceptable solution), or
b) at least understand the problem and tell me to restore/create the directory first, and then exit (poor option), or
c) ask me if I want it to (1) restore/create the directory and to restore the file or (2) cancel everything (best option in my opinion).

In any case, restore-trash should cope with the various problems that can occur when trying to restore the directory:
* it may be on a partition that has been unmounted,
* the user may have removed it with rm instead of trash, so it cannot be restore-trashed itself, or
* there may be several levels of directories missing (and they may be trashed or removed, or a mix of both), or
* there may be a permissions issue, or
* etc.

Thanks for working on this long-awaited little (but not so trivial) tool!

Revision history for this message
Andrea Francia (andrea-francia) wrote :

Hi,
  I'm the writer of trash-cli.

Would you test if the reported behaviour will occour with the latest development version of trash-cli?

To install the last version:
   sudo apt-get remove trash-cli
   sudo easy_install trash-cli

If you don't have easy_install you could install it with "apt-get install python-setuptools".
Please note that the new version of trash-cli uses a different command nams (trash-file instead of trash, trash-list instead of list-trash, trash-empty instead of empty-trash).

Revision history for this message
Don Cristóbal (doncristobal) wrote : Re: [Bug 310088] Re: restore-trash crashes if the original path does not exist (even if it's in the same trash can)

I did what you suggested:
> sudo apt-get remove trash-cli
> sudo apt-get install python-setuptools
> sudo easy_install trash-cli
>
Then I did the same procedure as before (trash-file everything from a
directory, trash-file the directory itself, try to restore-trash
(trash-restore?) one of the files.

A. If I try /restore-trash/:
> (... List of files ...)
> What file to restore [0..53]: 8
> Traceback (most recent call last):
> File "/usr/bin/restore-trash", line 5, in <module>
> pkg_resources.run_script('trash-cli==0.2.1', 'restore-trash')
> File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 448,
> in run_script
> self.require(requires)[0].run_script(script_name, ns)
> File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1173,
> in run_script
> exec script_code in namespace, namespace
> File "/usr/bin/restore-trash", line 39, in <module>
>
> File "build/bdist.linux-i686/egg/trashcli/trash.py", line 322, in
> restore
> File "build/bdist.linux-i686/egg/trashcli/filesystem.py", line 30,
> in move
> File "/usr/lib/python2.5/shutil.py", line 205, in move
> copy2(src,dst)
> File "/usr/lib/python2.5/shutil.py", line 96, in copy2
> copyfile(src, dst)
> File "/usr/lib/python2.5/shutil.py", line 52, in copyfile
> fdst = open(dst, 'wb')
> IOError: [Errno 2] No such file or directory:
> '/home/christoph/test/pons-ds.mobi'
B. If I try /trash-restore/:
> $ trash-restore
> Traceback (most recent call last):
> File "/usr/bin/trash-restore", line 5, in <module>
> pkg_resources.run_script('trash-cli==0.2.1', 'trash-restore')
> File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 448,
> in run_script
> self.require(requires)[0].run_script(script_name, ns)
> File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1172,
> in run_script
> script_code = compile(script_text,script_filename,'exec')
> File
> "/usr/lib/python2.5/site-packages/trash_cli-0.2.1-py2.5.egg/EGG-INFO/scripts/trash-restore",
> line 30
> class NoWrapFormatter(optparse.IndentedHelpFormatter) :
> ^
> IndentationError: expected an indented block

Up to you to draw conclusions... I'll be happy to help with further testing.

By the way, Nautilus cannot really handle the problem either, he just
returns an error message (instead of proposing to create the original
directory).

Good luck fixing this!

Revision history for this message
Don Cristóbal (doncristobal) wrote :

One more suggestion: Don't name the trash command "trash-file" unless there are absolutely compulsory reasons for it. My arguments against "trash-file":
* It is not intuitive and therefore unnecessarily difficult to memorise.
* It is unnecessarily long.
* Every change in the name of programs causes confusion, so the new solution should be a clear improvement (which it isn't).
* It is even wrong: Directories can be trashed, too.

Just "trash" was much better.

However, I welcome the renaming of "restore-trash" to "trash-restore", "list-trash" to "trash-list" etc. This is intuitive and allows the user to look for the appropriate command with the tab key.

Revision history for this message
Andrea Francia (andrea-francia) wrote : Re: [Bug 310088] Re: restore-trash crashes if the original path does not exist (even if it's in the same trash can)

Christoph Bloch wrote:
> One more suggestion: Don't name the trash command "trash-file" unless there are absolutely compulsory reasons for it. My arguments against "trash-file":
> * It is not intuitive and therefore unnecessarily difficult to memorise.
> * It is unnecessarily long.
> * Every change in the name of programs causes confusion, so the new solution should be a clear improvement (which it isn't).
> * It is even wrong: Directories can be trashed, too.
>
> Just "trash" was much better.
>
I had a long discussion about that with the fedora people.
The discussion started on:
    https://bugzilla.redhat.com/show_bug.cgi?id=448122

And it followed in

https://www.redhat.com/archives/fedora-devel-list/2008-October/msg00216.html

I would prefer "trash" as name but they don't allow me to name it
"trash" because "the name is too generic".

Revision history for this message
Andrea Francia (andrea-francia) wrote :

Andrea Francia wrote:
> And it followed in
>
> https://www.redhat.com/archives/fedora-devel-list/2008-October/msg00216.html
>

You can read a summary of the discussion on
http://fedoraproject.org/wiki/FWN/Issue147 or if it is down at
http://www.google.it/search?q=Fedora+Weekly+News+147

I really don't like the "trash-file" command name if someone is able to
find a better name or know or to make the fedora peoples change its idea
please inform me.

Changed in trash-cli (Ubuntu):
status: New → Incomplete
status: Incomplete → New
Changed in trash-cli (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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