From 195094cfaa073726a1442c4a125f0c09cd293ede Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Sun, 6 Nov 2022 16:17:04 +0100 Subject: xattr-tags-extension: avoid check xattr for mtp:// and gphoto2:// Some protocols (like mtp://), doesn't support xattr. In this case avoid to check the xattr-tags to not have poor performance. This patch blacklist mtp:// and gphoto2://. --- xattr-tags/caja-xattr-tags-extension.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xattr-tags/caja-xattr-tags-extension.c b/xattr-tags/caja-xattr-tags-extension.c index a00dc8d..cc420c7 100644 --- a/xattr-tags/caja-xattr-tags-extension.c +++ b/xattr-tags/caja-xattr-tags-extension.c @@ -50,6 +50,16 @@ typedef struct { GClosure *update_complete; } CajaXattrTagsHandle; +/* List of protocols that don't support xattr retriving, + * so we can skip it safetely + */ +static gchar *protocols_blacklist[] = { + "mtp://", + "gphoto2://", + + NULL +}; + /* Stolen code: why they didn't expose it!? * file: glocalfileinfo.c * function: hex_unescape_string @@ -107,8 +117,21 @@ static gchar *caja_xattr_tags_get_xdg_tags(CajaFileInfo *file) gchar *tags = NULL, *uri; GFile *location; GFileInfo *info; + int i; uri = caja_file_info_get_activation_uri (file); + for (i = 0 ; protocols_blacklist[i] ; i++) { + int l = strlen(protocols_blacklist[i]); + + if (strlen(uri) < l) + continue; + if (strncasecmp(uri, protocols_blacklist[i], l)) + continue; + + g_free (uri); + return NULL; + } + location = g_file_new_for_uri (uri); info = g_file_query_info (location, G_FILE_ATTRIBUTE_XATTR_XDG_TAGS, -- cgit v1.2.1