GNOME Bugzilla – Bug 509759
Migrate from GnomeVFS to GIO
Last modified: 2008-08-14 18:23:53 UTC
This will fix a major regression in GNOME 2.21: the trascan location in GnomeVFS is ~/.Trash while in GIO is (fd.o trash spec compliant) ~/.local/share/Trash (or, better, $XDG_DATA_HOME/Trash).
Currently, the only really working feature is "Open Trash", 'cause it opens the trash:// location, shared between gvfs and GnomeVFS.
Trashing is pretty easy in gio. Just call g_file_trash()
Created attachment 103518 [details] [review]
First attempt at a patch. Notes:
- not sure that the way it monitors the number of files in the trash is ideal
- no progress when emptying the trash
Looks ok to me from a quick lookover, at least for an initial version (having progress would be nice eventually).
(In reply to comment #3)
> First attempt at a patch. Notes:
Applied on my jhbuid sandbox: it works fine.
BTW and OT: we have an issue in nautilus: it don't moves files out from trash, but create copies :-|
> - no progress when emptying the trash
Do we really want to reimplement a progress dialog? Can't Nautilus provide some D-Bus magic to show its own (waiting for something in GTK+)?
i just reviewed (so far just the monitoring part).
i agree that the way it does the monitoring is not ideal. it's also subject to a race since the monitor isn't registered until after the initial count is made. even if it was the other way around, though, it would be subject to the opposite race.
imagine: 1 file in trash
== add monitor ==
*new file added to trash*
== count ==
(see 2 files)
== return to glib mainloop, dispatching monitor ==
(receive "new file" event), conclude "3 files in trash!"
i think a far better approach is something like:
dp = open (dir)
if (iterate (dp))
return FALSE; /* at least one file -> not empty. */
this is_empty function will be fast since it doesn't scan the entire directory.
2) keep track of "is empty" instead of count
3) on receiving "new file" event, obviously the directory is no longer empty
4) on receiving "deleted file" event, manually check the is_empty(). if you're worried about thrashing then schedule a 1-second work-deferal timer to check is_empty() (and keep rescheduling it as long as you're getting new delete events).
Committed revision 10648.
Re: empty detection
I talked to mclasen about this, and i think the best approach would be if the toplevel trash:/// location had a trash::num-items value with working change notification. Then it would be easy for apps to update counts and empty/full notifications.
I've not had time to do this though.
Guys, there still is a single reference to gnome-vfs in SVN trunk code:
can this be removed?
(In reply to comment #10)
> Guys, there still is a single reference to gnome-vfs in SVN trunk code: