From 4d9ebde225349096c68a66485c8c411400d61c59 Mon Sep 17 00:00:00 2001 From: div72 Date: Tue, 3 Sep 2024 15:46:22 +0300 Subject: [PATCH] util: use XDG_STATE_HOME for datadir on Flatpak $HOME is not writable by default on Flatpak, this caused the client to fail to use the default datadir. --- src/util/system.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/util/system.cpp b/src/util/system.cpp index e31bc297b7..5d4bd509e0 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -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