Skip to content

Commit

Permalink
xattr-tags-extension: avoid check xattr for mtp:// and gphoto2://
Browse files Browse the repository at this point in the history
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://.
  • Loading branch information
kreijack authored and raveit65 committed Nov 14, 2023
1 parent 652e145 commit 91cc466
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions xattr-tags/caja-xattr-tags-extension.c
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 91cc466

Please sign in to comment.