Skip to content

Commit

Permalink
util: use XDG_STATE_HOME for datadir on Flatpak
Browse files Browse the repository at this point in the history
$HOME is not writable by default on Flatpak, this caused the client to
fail to use the default datadir.
  • Loading branch information
div72 committed Sep 3, 2024
1 parent 4ae471e commit 4d9ebde
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,19 @@ fs::path GetDefaultDataDir()
} else {
pathRet = fs::path(pszHome);
}

char* container = getenv("container");

if (container && strcmp(container, "flatpak") == 0) {
char* state_home = getenv("XDG_STATE_HOME");

if (!state_home) {
return pathRet / ".local" / "state" / "GridcoinResearch";
}

return fs::path(state_home) / "GridcoinResearch";
}

#ifdef MAC_OSX
// The pathRet here represents the HOME directory. Apple
// applications are expected to store their files in
Expand Down

0 comments on commit 4d9ebde

Please sign in to comment.