After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 529971 - Restore from trash appears to do a file copy
Restore from trash appears to do a file copy
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: trash backend
git master
Other All
: High major
: ---
Assigned To: gvfs-maint
gvfs-maint
: 537224 545684 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-04-25 20:47 UTC by Pavel Šefránek
Modified: 2015-11-14 16:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
extremely ugly first take (16.70 KB, patch)
2008-07-22 18:51 UTC, A. Walton
needs-work Details | Review
First take on "Download" + "Steal" (46.00 KB, patch)
2008-08-30 09:45 UTC, Christian Kellner
none Details | Review
Another take ... (45.11 KB, patch)
2008-09-01 19:23 UTC, Christian Kellner
committed Details | Review

Description Pavel Šefránek 2008-04-25 20:47:08 UTC
originally reported here: https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/222150

When I restore a file from the trash by dragging it back to some other folder on my system, GVFS appears to copy it and then delete it, as if it were on another filesystem, rather than just moving it. This takes a long time, promotes fragmentation, and uses disk space. It should just change the file's path, like moving any other file on the system.
Comment 1 Cosimo Cecchi 2008-04-26 11:26:03 UTC
I see this too...for what I can see we're not doing anything fancy in Nautilus to restore files from trash (it should be just a simple g_file_move ()), so the bug may be in GVfs...reassigning.
Comment 2 Christian Neumair 2008-04-26 21:53:57 UTC
Files are trashed with g_file_trash(), which uses g_rename(). This is very snappy compared to the full-fledged file copy machinery (i.e. g_file_move()).

Although it is very fast, I am not sure whether this kind of trashing is a good idea. For instance, it does _not preserve file metadata_ (it is even explicitly removed in libnautilus-private/nautilus-file-operations.c:trash_files()).
Comment 3 Christian Neumair 2008-04-26 22:01:47 UTC
I forgot to mention that this also involves another issue: We do not mmap trash:/// URIs back to local files before carrying out operations on them. This could allow the g_file_move() code to use the GLocalFile move code, without falling back to copy [which is slow].
Comment 4 Cosimo Cecchi 2008-06-08 12:23:30 UTC
*** Bug 537224 has been marked as a duplicate of this bug. ***
Comment 5 Cosimo Cecchi 2008-06-08 12:24:29 UTC
Setting priority to High, this is a very visible regression.
Comment 6 André Klapper 2008-06-16 09:01:19 UTC
Can somebody come up with a patch for 2.22.3 (June 30)? I can only second Cosimo here.
Comment 7 André Klapper 2008-06-30 15:54:00 UTC
Hmm, pity. Anyway, anybody willing to come up with a patch?
Comment 8 Christian Neumair 2008-07-10 22:06:03 UTC
I just discussed this with Alex, and he proposed to add this functionality to gvfs in the following way:

* daemon/gvfsbackend.c - GVFSBackend should have a try_download() member function (cf. try_upload())
* client/gdaemonfile.c - g_daemon_file_copy should use try_download() for moving a file from a daemon source to a non-daemon destination (cf. G_VFS_DBUS_MOUNT_OP_UPLOAD)
* the trash backend should implement this try_download() function to fall back to g_rename(), in a similar way the burn backend uses try_upload().

Unfortunately, my exams are very near. Feel invited to work on it, though :)
Comment 9 A. Walton 2008-07-22 18:51:49 UTC
Created attachment 115039 [details] [review]
extremely ugly first take

Quick pass at this. Already notice there are going to be problems; we're assuming the copy+delete path, however g_rename() moves the file, so you get a pretty "Can't delete file" dialog after the copy operation succeeds. We may also need to patch Nautilus to correctly check for free space.

Probably needs some sanity checking, and a good overview of the fallback system would be very much appreciated. And there are a hundred other things I'm likely missing, feel free to point them out.
Comment 10 Christian Neumair 2008-08-01 19:33:59 UTC
*** Bug 545684 has been marked as a duplicate of this bug. ***
Comment 11 André Klapper 2008-08-29 15:36:23 UTC
while it's an annoying regression wasting electricity, cpu cycles and some cats, i think we have more important stuff that are real blockers. removing target milestone.
Comment 12 Pavel Šefránek 2008-08-29 21:02:19 UTC
Oh yeah, this _is_ a real issue. Please somebody take a look at this to get rid of this from 2.24. Thanks
Comment 13 Christian Kellner 2008-08-30 09:43:58 UTC
I am already at this.

Maybe I should explain whats going on:

1) Only implementing a "download" method that natively handles pulling from remote backends to the local filessystem is not enough since we also need to distinguish between copy and moves here.
Restoring from trash is going needs to kick in not in the copy control flow but in the move control flow, thus we don't need a download but rather a "steal" method. Ryan come up with the name.

The question that remains is that whether we should have seperate "Download" + "Steal" methods (and then maybe also a "Give" method to complete the "Upload" method) or just have a "Pull" and "Push" method with an additional "gboolean remove_source" in case of move (port upload to push, and add an aditional pull method).

Opinions, Alex?
Comment 14 Christian Kellner 2008-08-30 09:45:34 UTC
Created attachment 117625 [details] [review]
First take on "Download" + "Steal"

Here is my fist take which adds "Download" PLUS "Steal" and implements those inside the HTTP Backend and also in the Trash backend.
I tested this and that patch would indeed fix the bug.

gicmo@photon ~/Devel/gvfs % cat download.patch| diffstat
 client/gdaemonfile.c        |  210 +++++++++++++++++++++++++++------------
 common/gvfsdaemonprotocol.h |    2 
 daemon/Makefile.am          |    2 
 daemon/gvfsbackend.c        |   10 +
 daemon/gvfsbackend.h        |   30 +++++
 daemon/gvfsbackendhttp.c    |  235 +++++++++++++++++++++++++++++++++++++++++---
 daemon/gvfsbackendtrash.c   |  130 ++++++++++++++++++++++++
 daemon/gvfsjobdownload.c    |  211 +++++++++++++++++++++++++++++++++++++++
 daemon/gvfsjobdownload.h    |   66 ++++++++++++
 daemon/gvfsjobsteal.c       |  226 ++++++++++++++++++++++++++++++++++++++++++
 daemon/gvfsjobsteal.h       |   66 ++++++++++++
Comment 15 Christian Kellner 2008-09-01 19:23:42 UTC
Created attachment 117798 [details] [review]
Another take ...

This time we only have Push and Pull, not Give, Steal, Upload, Download. 

I quite the Master:
"I don't think it matters a lot really, but I'd personally lean towards
the "less methods" way."
Comment 16 Christian Kellner 2008-09-01 21:23:46 UTC
Committed a slightly different version to svn trunk. Hopefully this is dead now. ;-)

2008-09-01  Christian Kellner  <gicmo@gnome.org>

	* daemon/gvfsjobpull.c:
	* daemon/gvfsjobpull.h:
	New daemon method to pull files from daemons to the local
	file system.

	* daemon/gvfsjobpush.c:
	* daemon/gvfsjobpush.h:
	New daemon method to push local files to daemons. (Replaces
	Upload)

	* daemon/gvfsjobupload.c:
	* daemon/gvfsjobupload.h:
	Replaced by Push.

	* common/gvfsdaemonprotocol.h:
	* daemon/Makefile.am:
	* daemon/gvfsbackend.c:
	* daemon/gvfsbackend.h:
	Add Push and Pull. Remove Upload.

	* client/gdaemonfile.c:	
	New transfer logic. In case of move try push/pull (with
	remove_source set to TRUE) first then fallback. In case of copy
	try push/pull first then fallback. Use the same logic for
	both cases.

	* daemon/gvfsbackendburn.c:
	Port Upload to Push.
	
	* daemon/gvfsbackendtrash.c:
	Implement the Pull method. That should fix bug #529971