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 782311 - inode/directory is treated as a subclass of application/octet-stream
inode/directory is treated as a subclass of application/octet-stream
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-05-08 02:13 UTC by Evan Welsh
Modified: 2018-05-24 19:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
View of an unfiltered search in my music folder. (252.66 KB, image/png)
2017-05-08 02:16 UTC, Evan Welsh
  Details
Search filtered for files. (264.38 KB, image/png)
2017-05-08 02:16 UTC, Evan Welsh
  Details
Search filtered for folders. (125.86 KB, image/png)
2017-05-08 02:17 UTC, Evan Welsh
  Details
xdgmime: fix special case for mime_type_subclass (1.70 KB, patch)
2017-05-10 16:30 UTC, Alexandru Pandelea
none Details | Review
xdgmime: fix special case for mime_type_subclass (2.68 KB, patch)
2017-05-11 15:41 UTC, Alexandru Pandelea
none Details | Review
xdgmime: fix special case for mime_type_subclass (2.99 KB, patch)
2017-05-16 09:16 UTC, Alexandru Pandelea
committed Details | Review

Description Evan Welsh 2017-05-08 02:13:07 UTC
When 'Files' is selected folders are still shown. However, if 'Folders' is selected files are not shown.
Comment 1 Evan Welsh 2017-05-08 02:16:10 UTC
Created attachment 351320 [details]
View of an unfiltered search in my music folder.
Comment 2 Evan Welsh 2017-05-08 02:16:44 UTC
Created attachment 351321 [details]
Search filtered for files.
Comment 3 Evan Welsh 2017-05-08 02:17:08 UTC
Created attachment 351323 [details]
Search filtered for folders.
Comment 4 Alexandru Pandelea 2017-05-10 16:29:55 UTC
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
Comment 5 Alexandru Pandelea 2017-05-10 16:30:35 UTC
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.
Comment 6 Philip Withnall 2017-05-11 07:38:40 UTC
Review of attachment 351566 [details] [review]:

This looks reasonable, but can you please add some unit tests in gio/tests/contenttype.c for it?
Comment 7 Alexandru Pandelea 2017-05-11 15:41:13 UTC
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.
Comment 8 Philip Withnall 2017-05-16 08:07:50 UTC
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.
Comment 9 Alexandru Pandelea 2017-05-16 09:16:38 UTC
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.
Comment 10 Philip Withnall 2017-05-16 10:15:57 UTC
Review of attachment 351951 [details] [review]:

Great, thanks
Comment 11 Philip Withnall 2017-05-16 10:17:11 UTC
Attachment 351951 [details] pushed as eb7b796 - xdgmime: fix special case for mime_type_subclass
Comment 12 Daniel Macks 2017-10-23 16:30:38 UTC
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
Comment 13 Philip Withnall 2017-10-25 12:06:35 UTC
(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?
Comment 14 Daniel Macks 2017-10-26 06:52:35 UTC
Ahah! OS X defaults to use gosxconenttype rather than gcontenttype+xdgmime, so it needs some analogous patch to what is discussed here.
Comment 15 GNOME Infrastructure Team 2018-05-24 19:31:36 UTC
-- 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.