Repository navigation
Conversation
Pi Pocket kept everything in one folder, `~/.pi-pocket`: the database, people and their tokens, uploads, worktrees, extension drop-ins, the tunnel's log, and the browser's profile. That is not where any of them belong, and it put secrets beside caches. Each part now goes where the XDG base directory spec puts it: settings in `~/.config/pi-pocket`, the database and what sessions write in `~/.local/share/pi-pocket`, the tunnel's log in `~/.local/state/pi-pocket`, and the profile and downloaded cloudflared in `~/.cache/pi-pocket`. `XDG_*_HOME` moves them, and `PI_POCKET_CONFIG_DIR`, `PI_POCKET_DATA_DIR`, `PI_POCKET_STATE_DIR`, and `PI_POCKET_CACHE_DIR` name each one itself: the `--data` option and `PI_POCKET_DIR`, which named one folder, are gone. An older `~/.pi-pocket` moves into the new folders once (`dirs.ts`), entry by entry, and only where the destination has nothing: a migration cut off midway finishes on the next start, an unknown file stays where it is with a line saying so, a database already in the data folder is kept and named rather than silently passed over, and a Pi Pocket still running on the old folder stops the migration with a message instead of moving a live database. Files that older messages and isolated sessions name by their old absolute path are reported too, as they now live under the data folder. `host.dataDir` keeps meaning the data folder and no interface in `types/pocket.d.ts` changes; the lock stays in the data folder, since it guards that database and says which folder is taken. The NixOS module sets all four folders to `dataDir`, so an existing deployment keeps its files where they are.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pi Pocket keeps everything in one folder,
~/.pi-pocket: the database, people and their tokens, uploads, worktrees, extension drop-ins, the tunnel's log, and the browser's profile. Nothing there follows the XDG base directory spec, and it mixes secrets with caches.This splits them by kind, the way the spec asks:
~/.config/pi-pocketconfig.json(people, roles, tokens, settings),launcher.json~/.local/share/pi-pocketpocket.sqliteand its lock,push.json,uploads/,worktrees/,repos/,gallery/,themes/,extensions/~/.local/state/pi-pocket~/.cache/pi-pocketcloudflared, the built-in browser's profileXDG_*_HOMEmoves them.PI_POCKET_CONFIG_DIR,PI_POCKET_DATA_DIR,PI_POCKET_STATE_DIR, andPI_POCKET_CACHE_DIRname each one itself, so the--dataoption andPI_POCKET_DIRare gone (they named one folder, which is no longer the shape). The launcher passes the four resolved folders to the server, so the two always agree.Migration.
src/server/dirs.tsmoves an older~/.pi-pocketinto the four, once, entry by entry:harness.lock) stops the migration with a message, rather than moving a database out from under it;.partialname and renames it into place, so a copy cut short is never mistaken for a finished one;Compatibility.
host.dataDirkeeps meaning the data folder, and nothing intypes/pocket.d.tschanges, so no module or reference page gets a newSinceline. The lock stays in the data folder: it guards that database and its message says which folder is taken, so a second instance with its own data folder still runs. The NixOS module pins all four folders todataDir, so an existing service deployment keeps its files exactly where they are rather than starting on empty folders.Tested.
npm run format,npm run check,npm run lint, andnpm test: 356 tests, 315 pass, 8 fail — the same 8test/pi-sessions.test.tstests that fail onmainhere before any change (this machine's Pi session files), plusmodel-refreshintermittently. New tests intest/dirs.test.tscover the XDG precedence (including relative, empty, andPI_POCKET_*_DIRoverrides), the folder modes, a full legacy migration (database with-wal/-shm, extensions, worktrees, repos, tunnel log, cloudflared, browser profile), idempotency, no overwriting, the database-already-there case, and the still-running case.test/qol.test.tsnow checks a guest cannot readconfig.json,launcher.json,pocket.sqlite,push.json, the tunnel log, the browser's cookies, or what a migration left in the old folder. Also ran a throwaway-HOMEend-to-end check: a fake legacy folder migrates into the four, an unknown file stays behind with a line, and a second run does nothing.One known effect: documents written before the upgrade name files by their old absolute path — an older message's attachments, an isolated session's worktree, a PiP clone in a session's folder. Those paths move with everything else, and the migration log says so, but the old messages and sessions then point at the old folder. Keeping
~/.pi-pocket(or symlinkinguploads/,worktrees/, andrepos/back to the data folder) keeps them working; rewriting the stored paths would be a separate change. Say if you would like that in this PR instead.Also updated the docs the paths appear in (
README.md,AGENTS.md,SECURITY.md,docs/**,site/**) and the NixOS module and its tests.