GNOME Bugzilla – Bug 777507
Recent view sorting incorrectly
Last modified: 2017-02-20 10:00:46 UTC
Recent contains files that are not actually recent, or are not sorted according to most recently edited or accessed. There was some question in the #nautilus irc channel about where nautilus gets the Recent file list information from, and what's responsible for updating that list. It was recommended I post this bug report as a collection place for further info. I'm running gnome 3.22 and nautilus 3.22 as well on an Ubuntu 16.10 system with 16GB of ram... not that it should make a dif. :) Others in the thread were seeing oddities in the Recent files info including (I think) a file that hadn't been touched since 2015. :) Thanks to everyone involved for the help, and I love the Recent view. When it works it's a real time-saver. -C
The sort order is based on atime currently, which is problematic, because some daemons (i.e. dropbox) randomly accesses files and changes atime... I think the best what we can do here is the usage of gtk_recent_info_get_modified for sorting the files (same as it is done in GtkRecentChooser and other GTK+ applications). The modified date from GtkRecentInfo is usually updated when opening and saving files in GTK+ applications, so this is what we want... I think sorting the files in Nautilus is the right way. So I've prepared patches, which add (GLib) and set (GVfs) G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute. I am also playing with Nautilus, but I am not sure I am able to do it :-D I would change the product of this bug to GLib once we prepare (and test) all patches... Just a note that the following bug report might be relevant/duplicate: https://bugzilla.gnome.org/show_bug.cgi?id=773142
Created attachment 343867 [details] [review] fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute Add filesystem attribute to propagate time, when the metadata for the file in "recent:///" was last changed. This attribute is needed for sorting recent backend files in client applications.
Created attachment 343868 [details] [review] recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute G_FILE_ATTRIBUTE_TIME_ACCESS is used for sorting currently, however, it causes troubles, because some daemons (i.e. dropbox) access files and updates its timestamps itself. This attribute propagates time when the metadata was last changed, which is what we need for sorting in client applications.
Created attachment 344807 [details] [review] general: add recency sort for recent files The sort order is based on atime currently, which is problematic, because some daemons (i.e. dropbox) randomly accesses files and changes atime... Instead we should just take into account when the user accessed. Recently glib and gvfs added a new attribute in the recent namespaces G_FILE_ATTRIBUTE_RECENT_MODIFIED or "recent::modified" that we can use to sort correctly the files in Recent. This patch adds this attribute and corresponding columns etc. to the file data and views and makes it the default sorting when in Recent.
Can you try it Ondrej? I didn't manage to get the attribute from the files (I bet I'm running gvfs daemon from the system, and I forgot how to reset that to the jhbuild one). You can add the column in preferences to display the date of recency (if it works correctly).
Review of attachment 344807 [details] [review]: NAUTILUS_DATE_TYPE_RECENCY has to be added in the swith, otherwise icon captions doesn't work... nautilus/src/nautilus-vfs-file.c: In function ‘vfs_file_get_date’: nautilus/src/nautilus-vfs-file.c:299:5: warning: enumeration value ‘NAUTILUS_DATE_TYPE_RECENCY’ not handled in switch [-Wswitch] switch (date_type) ::: src/nautilus-column-utilities.c @@ +130,3 @@ "description", _("The location of the file."), NULL)); + This is probably unwanted... ::: src/nautilus-file.c @@ +3064,3 @@ } + recency = g_file_info_get_attribute_uint32 (info, "recent::modified"); It is int64... (nautilus:589): GLib-GIO-CRITICAL **: _g_file_attribute_value_get_uint32: assertion 'attr->type == G_FILE_ATTRIBUTE_TYPE_UINT32' failed Why not use G_FILE_ATTRIBUTE_RECENT_MODIFIED? Is that because of backward compatibility? Maybe I should do the same in GVfs... ::: src/nautilus-file.h @@ +60,3 @@ NAUTILUS_FILE_SORT_BY_TRASHED_TIME, + NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE, + NAUTILUS_FILE_SORT_BY_RECENCY, Is the comma wanted here? It is not allowed by C89 if I am not wrong, does Nautilus require C99 in that case? @@ +528,3 @@ NAUTILUS_DATE_TYPE_ACCESSED, + NAUTILUS_DATE_TYPE_TRASHED, + NAUTILUS_DATE_TYPE_RECENCY, dtto
(In reply to Carlos Soriano from comment #5) > Can you try it Ondrej? Sure. It seems it works as expected with the changes I mentioned in the review. > I didn't manage to get the attribute from the files > (I bet I'm running gvfs daemon from the system, and I forgot how to reset > that to the jhbuild one). It should be enough to run the following (/opt/gnome is my jbuild prefix): pkill gvfsd-recent; jhbuild run /opt/gnome/usr/libexec/gvfsd-recent You can check that the attribute is really set by the following: jhbuild run gvfs-ls -a "recent::modified" recent:/// > You can add the column in preferences to display the date of recency (if it > works correctly). Columns are not editable in recent view I am afraid, but it is possible to add it as icon captions and looks ok...
Hmm, Nautilus should probably update the recent date each time some file is opened from it, because the time is not updated with this patches if you open file in some non-gio-based application, but atime was updated before...
Created attachment 345234 [details] [review] general: add recency sort for recent files The sort order is based on atime currently, which is problematic, because some daemons (i.e. dropbox) randomly accesses files and changes atime... Instead we should just take into account when the user accessed. Recently glib and gvfs added a new attribute in the recent namespaces G_FILE_ATTRIBUTE_RECENT_MODIFIED or "recent::modified" that we can use to sort correctly the files in Recent. This patch adds this attribute and corresponding columns etc. to the file data and views and makes it the default sorting when in Recent.
Hey, thanks for the review. The white line was wanted, just sneakily put it in the patch :) About c89, true, I wasn't aware of that, I changed it. However I think it's fine if we use c99 or c11 by now... About Nautilus updating the recent date, sounds like the wrong thing to do. If we do that, some files used in an application will show up in recent, others not (the ones opened directly in the application). So I guess better be consistent in here no? Those applications should update it, although yeah it's a pitty for the majority of apps, since they probably won't do it...but what can we do? Maybe that was one of the reasons to not use xbel on the first place... :/
Looks ok to me now, so let's move it to GLib/GIO for review...
Review of attachment 343867 [details] [review]: ::: gio/gfileinfo.h @@ +870,3 @@ + * + * A key in the "recent" namespace for getting time, when the metadata for the + * file in "recent:///" was last changed. Corresponding #GFileAttributeType is Nitpick: use `backticks` to use monospaced font on literals like `recent:///` @@ +875,3 @@ + * Since: 2.52 + **/ +#define G_FILE_ATTRIBUTE_RECENT_MODIFIED "recent::modified" /* int64 (time_t) */ Needs adding to gio-sections.txt for the documentation.
Created attachment 345409 [details] [review] fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute Add filesystem attribute to propagate time, when the metadata for the file in "recent:///" was last changed. This attribute is needed for sorting recent backend files in client applications.
Created attachment 345410 [details] [review] fileinfo: Use monospaced font for uris Some uris are in quotes, some in backticks, let's unify it.
Created attachment 345411 [details] [review] doc: Unify order of file attributes Order of file attributes in docs is different than in source codes. I don't really think it is intended. Let's unify it.
Review of attachment 345410 [details] [review]: Looks good to push this one now, thanks.
Comment on attachment 345410 [details] [review] fileinfo: Use monospaced font for uris Attachment 345410 [details] pushed as 4539579 - fileinfo: Use monospaced font for uris Thanks for the review though this patch was one from the least significant. We need to push attachment 345409 [details] [review]...
All the patches look fine to me, but I’m not a GLib maintainer so can’t ack new features like this. Matthias?
Attachment 345409 [details] pushed as 006a7d0 - fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute Attachment 345411 [details] pushed as 7dbc072 - doc: Unify order of file attributes
Created attachment 345625 [details] [review] recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute G_FILE_ATTRIBUTE_TIME_ACCESS is used for sorting currently, however, it causes troubles, because some daemons (i.e. dropbox) access files and updates its timestamps itself. This attribute propagates time when the metadata was last changed, which is what we need for sorting in client applications.
Comment on attachment 345625 [details] [review] recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute Attachment 345625 [details] pushed as febe35c - recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute
Attachment 345234 [details] pushed as 048c6ef - general: add recency sort for recent files