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 777507 - Recent view sorting incorrectly
Recent view sorting incorrectly
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-01-19 20:23 UTC by C.M.Rogers
Modified: 2017-02-20 10:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute (1.26 KB, patch)
2017-01-20 08:57 UTC, Ondrej Holy
none Details | Review
recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute (1.84 KB, patch)
2017-01-20 08:58 UTC, Ondrej Holy
none Details | Review
general: add recency sort for recent files (11.58 KB, patch)
2017-02-02 19:45 UTC, Carlos Soriano
none Details | Review
general: add recency sort for recent files (12.31 KB, patch)
2017-02-08 15:08 UTC, Carlos Soriano
committed Details | Review
fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute (1.80 KB, patch)
2017-02-10 09:39 UTC, Ondrej Holy
committed Details | Review
fileinfo: Use monospaced font for uris (1.85 KB, patch)
2017-02-10 09:40 UTC, Ondrej Holy
committed Details | Review
doc: Unify order of file attributes (2.20 KB, patch)
2017-02-10 09:40 UTC, Ondrej Holy
committed Details | Review
recent: Set G_FILE_ATTRIBUTE_RECENT_MODIFED attribute (1.87 KB, patch)
2017-02-13 13:28 UTC, Ondrej Holy
committed Details | Review

Description C.M.Rogers 2017-01-19 20:23:35 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
Comment 1 Ondrej Holy 2017-01-20 08:56:10 UTC
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
Comment 2 Ondrej Holy 2017-01-20 08:57:51 UTC
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.
Comment 3 Ondrej Holy 2017-01-20 08:58:27 UTC
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.
Comment 4 Carlos Soriano 2017-02-02 19:45:58 UTC
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.
Comment 5 Carlos Soriano 2017-02-02 19:47:44 UTC
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).
Comment 6 Ondrej Holy 2017-02-07 08:53:35 UTC
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
Comment 7 Ondrej Holy 2017-02-07 08:53:59 UTC
(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...
Comment 8 Ondrej Holy 2017-02-07 09:04:44 UTC
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...
Comment 9 Carlos Soriano 2017-02-08 15:08:06 UTC
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.
Comment 10 Carlos Soriano 2017-02-08 15:11:41 UTC
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... :/
Comment 11 Ondrej Holy 2017-02-09 18:38:24 UTC
Looks ok to me now, so let's move it to GLib/GIO for review...
Comment 12 Philip Withnall 2017-02-09 18:50:14 UTC
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.
Comment 13 Ondrej Holy 2017-02-10 09:39:58 UTC
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.
Comment 14 Ondrej Holy 2017-02-10 09:40:13 UTC
Created attachment 345410 [details] [review]
fileinfo: Use monospaced font for uris

Some uris are in quotes, some in backticks, let's unify it.
Comment 15 Ondrej Holy 2017-02-10 09:40:20 UTC
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.
Comment 16 Philip Withnall 2017-02-10 10:49:04 UTC
Review of attachment 345410 [details] [review]:

Looks good to push this one now, thanks.
Comment 17 Ondrej Holy 2017-02-13 09:37:29 UTC
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]...
Comment 18 Philip Withnall 2017-02-13 11:32:02 UTC
All the patches look fine to me, but I’m not a GLib maintainer so can’t ack new features like this. Matthias?
Comment 19 Matthias Clasen 2017-02-13 13:14:08 UTC
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
Comment 20 Ondrej Holy 2017-02-13 13:28:47 UTC
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 21 Ondrej Holy 2017-02-13 13:30:31 UTC
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
Comment 22 Carlos Soriano 2017-02-20 10:00:40 UTC
Attachment 345234 [details] pushed as 048c6ef - general: add recency sort for recent files