mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-11 13:19:22 +01:00
gfile: Fallback to fast-content-type if content-type is not set
The G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE attribute doesn't have to be always set. See https://gitlab.gnome.org/GNOME/gvfs/-/merge_requests/68 for more details. In that case, the g_file_query_default_handler function fails with the "No application is registered as handling this file" error. Let's fallback to the "standard::fast-content-type" attribute instead to fix issues when opening such files. https://gitlab.gnome.org/GNOME/nautilus/-/issues/1425
This commit is contained in:
parent
204b4dc285
commit
35953b5371
10
gio/gfile.c
10
gio/gfile.c
@ -6839,7 +6839,8 @@ g_file_query_default_handler (GFile *file,
|
|||||||
g_free (uri_scheme);
|
g_free (uri_scheme);
|
||||||
|
|
||||||
info = g_file_query_info (file,
|
info = g_file_query_info (file,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||||
|
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
|
||||||
0,
|
0,
|
||||||
cancellable,
|
cancellable,
|
||||||
error);
|
error);
|
||||||
@ -6849,6 +6850,8 @@ g_file_query_default_handler (GFile *file,
|
|||||||
appinfo = NULL;
|
appinfo = NULL;
|
||||||
|
|
||||||
content_type = g_file_info_get_content_type (info);
|
content_type = g_file_info_get_content_type (info);
|
||||||
|
if (content_type == NULL)
|
||||||
|
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
|
||||||
if (content_type)
|
if (content_type)
|
||||||
{
|
{
|
||||||
/* Don't use is_native(), as we want to support fuse paths if available */
|
/* Don't use is_native(), as we want to support fuse paths if available */
|
||||||
@ -6890,6 +6893,8 @@ query_default_handler_query_info_cb (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
content_type = g_file_info_get_content_type (info);
|
content_type = g_file_info_get_content_type (info);
|
||||||
|
if (content_type == NULL)
|
||||||
|
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
|
||||||
if (content_type)
|
if (content_type)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
@ -6960,7 +6965,8 @@ g_file_query_default_handler_async (GFile *file,
|
|||||||
g_free (uri_scheme);
|
g_free (uri_scheme);
|
||||||
|
|
||||||
g_file_query_info_async (file,
|
g_file_query_info_async (file,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||||
|
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
|
||||||
0,
|
0,
|
||||||
io_priority,
|
io_priority,
|
||||||
cancellable,
|
cancellable,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user