Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/libaudcore/tuple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,28 @@ static StringBuf extract_domain(const char * start)
return name;
}

/* Sandboxed apps (Flatpak and Snap) receive granted files through the
* document portal as /run/user/<uid>/doc/<id>/<name>. <id> is not the
* real directory that contains the file. */
static bool is_document_portal_path(const char * path)
{
Comment thread
cfgnunes marked this conversation as resolved.
Resolved
#ifdef __linux__
if (!path || strncmp(path, "/run/user/", 10))
return false;

const char * p = path + 10;
if (!g_ascii_isdigit(*p))
return false;

while (g_ascii_isdigit(*p))
p++;

return !strncmp(p, "/doc/", 5) || !strcmp(p, "/doc");
#else
return false;
#endif
}

EXPORT void Tuple::generate_fallbacks()
{
if (!data)
Expand Down Expand Up @@ -847,6 +869,11 @@ EXPORT void Tuple::generate_fallbacks()
sep = G_DIR_SEPARATOR;
}

// leave artist and album empty for sandboxed applications,
// the document portal hides the actual host filesystem path
if (is_document_portal_path(s))
return;

StringBuf buf = str_copy(s);

char * first = split_folder(buf, sep);
Expand Down