summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffredo Baroncelli <[email protected]>2022-11-06 16:17:04 +0100
committerraveit65 <[email protected]>2023-11-14 16:12:58 +0100
commit91cc4665e9d707fd1015fb5c952816d13ef37693 (patch)
treeefc25937b6a9b7b5e47b0b00b701ae12d5579180
parent652e145d2c5e2a9658eed7a665fe5a295503940b (diff)
downloadcaja-extensions-1.26.tar.bz2
caja-extensions-1.26.tar.xz
xattr-tags-extension: avoid check xattr for mtp:// and gphoto2://1.26
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://.
-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 a3c8993..ab6450d 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,