summaryrefslogtreecommitdiff
path: root/xattr-tags
diff options
context:
space:
mode:
authorGoffredo Baroncelli <[email protected]>2022-11-06 16:17:04 +0100
committerraveit65 <[email protected]>2023-08-30 15:28:51 +0200
commit195094cfaa073726a1442c4a125f0c09cd293ede (patch)
treee3747efdc8cb081c6fcc265edebf23b655b463c0 /xattr-tags
parent9801ebca7a7072b68da3c816a20558080316bb06 (diff)
downloadcaja-extensions-195094cfaa073726a1442c4a125f0c09cd293ede.tar.bz2
caja-extensions-195094cfaa073726a1442c4a125f0c09cd293ede.tar.xz
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://.
Diffstat (limited to 'xattr-tags')
-rw-r--r--xattr-tags/caja-xattr-tags-extension.c23
1 files changed, 23 insertions, 0 deletions
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,