GNOME Bugzilla – Bug 782311
inode/directory is treated as a subclass of application/octet-stream
Last modified: 2018-05-24 19:31:36 UTC
When 'Files' is selected folders are still shown. However, if 'Folders' is selected files are not shown.
Created attachment 351320 [details] View of an unfiltered search in my music folder.
Created attachment 351321 [details] Search filtered for files.
Created attachment 351323 [details] Search filtered for folders.
As mentioned here: https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html, "All streamable types (ie, everything except the inode/* types) are subclasses of application/octet-stream.", but GLib currently matches anything with application/octet-stream. When Nautilus filters for "files" it checks for matches with application/octet-stream so that's why folders are not filtered out
Created attachment 351566 [details] [review] xdgmime: fix special case for mime_type_subclass Currently, all mime types are considered subclasses of application/octet-stream, but according to the freedesktop standard, everything but the inode/* types is a subclass of application/octet-stream. Update the special case for application/octet-stream so that all types but inode/* will match with it.
Review of attachment 351566 [details] [review]: This looks reasonable, but can you please add some unit tests in gio/tests/contenttype.c for it?
Created attachment 351647 [details] [review] xdgmime: fix special case for mime_type_subclass Currently, all mime types are considered subclasses of application/octet-stream, but according to the freedesktop standard, everything but the inode/* types is a subclass of application/octet-stream. Update the special case for application/octet-stream so that all types but inode/* will match with it and add unit test for it.
Review of attachment 351647 [details] [review]: A few nitpicks. ::: gio/tests/contenttype.c @@ +328,3 @@ +test_type_is_a_special_case (void) +{ + gboolean res; Add a call to `g_test_bug ("782311");` at the top of the function to give the bug reference. @@ +330,3 @@ + gboolean res; + + //Everything but inode/* is application/octet-stream Please use /* C++-style comments */ as per the coding style for GLib. @@ +332,3 @@ + //Everything but inode/* is application/octet-stream + res = g_content_type_is_a ("inode/directory", "application/octet-stream"); + g_assert(!res); Put a space before the `(`. You can also use g_assert_false here instead of g_assert, to simplify things a bit. @@ +334,3 @@ + g_assert(!res); + res = g_content_type_is_a ("anything", "application/octet-stream"); + g_assert(res); You can use g_assert_true here instead of g_assert.
Created attachment 351951 [details] [review] xdgmime: fix special case for mime_type_subclass Currently, all mime types are considered subclasses of application/octet-stream, but according to the freedesktop standard, everything but the inode/* types is a subclass of application/octet-stream. Update the special case for application/octet-stream so that all types but inode/* will match with it and add unit test for it.
Review of attachment 351951 [details] [review]: Great, thanks
Attachment 351951 [details] pushed as eb7b796 - xdgmime: fix special case for mime_type_subclass
Building glib-2.54.1 on OS X 10.13, the test for this bug fails. According to gio/tests/contenttype.log: GLib-GIO:ERROR:contenttype.c:338:test_type_is_a_special_case: 'res' should be TRUE # Bug Reference: http://bugzilla.gnome.org/782311
(In reply to Daniel Macks from comment #12) > Building glib-2.54.1 on OS X 10.13, the test for this bug fails. According > to gio/tests/contenttype.log: > > GLib-GIO:ERROR:contenttype.c:338:test_type_is_a_special_case: 'res' should > be TRUE > # Bug Reference: http://bugzilla.gnome.org/782311 That’s weird; I can’t see why it should be behaving differently on OS X. Would you be able to run the test under gdb and trace through the path taken in xdg_mime_mime_type_subclass() to work out where it’s going wrong?
Ahah! OS X defaults to use gosxconenttype rather than gcontenttype+xdgmime, so it needs some analogous patch to what is discussed here.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1266.