Repository navigation
Conversation
| } else if (Platform.isLinux) { | ||
| // Flatpak detection: use XDG_DATA_HOME instead of ~/.stackwallet. | ||
| final flatpakId = Platform.environment['FLATPAK_ID']; | ||
| if (flatpakId != null || File('/.flatpak-info').existsSync()) { | ||
| // Resolve the persistent data root. Prefer XDG_DATA_HOME when set. | ||
| // Otherwise fall back to $HOME/.local/share, but only if HOME is | ||
| // available. If neither is set we leave the data dir unchanged and | ||
| // let StackFileSystem use its default, rather than crashing. | ||
| final home = Platform.environment['HOME']; | ||
| final xdgDataHome = Platform.environment['XDG_DATA_HOME'] ?? | ||
| (home != null ? path.join(home, '.local', 'share') : null); | ||
|
|
||
| if (xdgDataHome != null) { | ||
| final flatpakDataDir = | ||
| path.join(xdgDataHome, AppConfig.appDefaultDataDirName); | ||
|
|
||
| // Migration: move legacy data from $HOME/.stackwallet into the new | ||
| // location, but only when the legacy dir exists and the new one does | ||
| // not. Best-effort: never crash if the move fails. | ||
| if (home != null) { | ||
| final legacyDir = Directory( | ||
| path.join(home, '.${AppConfig.appDefaultDataDirName}'), | ||
| ); | ||
| final newDir = Directory(flatpakDataDir); | ||
| if (legacyDir.existsSync() && !newDir.existsSync()) { | ||
| try { | ||
| await Directory(xdgDataHome).create(recursive: true); | ||
| await legacyDir.rename(newDir.path); | ||
| } catch (_) { | ||
| // If rename fails (e.g. different filesystem), fall back to | ||
| // using the new path anyway. The user can manually move data. | ||
| } | ||
| } | ||
| } | ||
|
|
||
| StackFileSystem.setDesktopOverrideDir(flatpakDataDir); | ||
| } | ||
| } |
There was a problem hiding this comment.
this breaks setDesktopOverrideDir
| // location or the -d launch flag) keep logs under that persistent root | ||
| // so they follow the data directory rather than landing in the | ||
| // application documents directory. | ||
| if (_overrideDesktopDirPath != null) { |
There was a problem hiding this comment.
Whole file needs different changes.
Although I do agree the logs dir currently has some issues re _overrideDesktopDirPath
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## staging #1369 +/- ##
===========================================
+ Coverage 13.92% 14.01% +0.09%
===========================================
Files 1139 1140 +1
Lines 114707 114849 +142
===========================================
+ Hits 15976 16100 +124
- Misses 98731 98749 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Converting to draft pending changes in response to the reviews and requested changes above |
Inside Flatpak the data root becomes $XDG_DATA_HOME/<app> instead of ~/.<app>, so it lives in the sandbox's own persistent directory. Existing data is migrated once per process, before Hive opens: lock the legacy Hive db, copy the tree to <root>.migrating, flush it, verify every file by SHA-256, write a completion marker and rename it into place. Legacy data is never modified or deleted and any failure falls back to it, so the manifests keep --filesystem=~/.<app> to keep that fallback readable. The -d launch flag still takes precedence over all of this. closes #1249
495d0af to
d4b7ab9
Compare
|
#1430 fixed the same "data doesn't persist" symptom the opposite way, keeping data in the home folder outside the sandbox with --filesystem=~/.:create. We need to pick one approach. If #1369 stays, it should move the old data folder rather than copy it, or a password reset (#1455) leaves the old copy behind. |
Inside Flatpak the data root becomes $XDG_DATA_HOME/<app> instead of ~/.<app>, so it lives in the sandbox's own persistent directory. Existing data is migrated once per process, before Hive opens: lock the legacy Hive db, copy the tree to <root>.migrating, flush it, verify every file by SHA-256, write a completion marker and rename it into place. Legacy data is never modified or deleted and any failure falls back to it, so the manifests keep --filesystem=~/.<app> to keep that fallback readable. The -d launch flag still takes precedence over all of this. closes #1249
The verified copy left a full second copy of the wallet data, password and secure store in ~/.<app>. A desktop reset of the new root does not touch it, so the old data survived a "forgot password" reset. Rename the legacy root when possible. Otherwise (always the case inside Flatpak, where it is a bind mount) remove its contents once the copy is verified and in place. A marker written first lets the next launch finish an interrupted removal; legacy data written after a completed migration without that marker is left alone.
closes #1249
Refresh review (2026-11-10)
Refresh review keeps the latest migration flow (rename when possible; otherwise copy, verify, publish, then resume legacy cleanup) and serializes first-launch migration with an XDG sibling lock, including when Hive has not created
dbinfo.lock. A cross-process regression test verifies only one migration proceeds and the wallet data is preserved. Flatpak manifests retain the required:createpermission.Checks: migration, environment, and override tests (14 passed); targeted
flutter analyzeclean.