fix(server): default data dir to ~/.sideshow with one-time migration#162
Merged
Conversation
The default data directory was package-relative (), which is read-only under (EACCES even after the #157 mkdir guard) and wiped on every removed 92 packages, and changed 1 package in 4s upgrade — silent data loss. Move the default to (user-owned, always writable, survives reinstalls). A one-time file-level migration copies any existing sideshow.{db,db-wal,db-shm,json} from the old location to the new one on first boot, only when using default paths. SIDESHOW_DATA/SIDESHOW_DB overrides are unchanged and skip the migration. The migration is idempotent (never overwrites files at the new location) and composes with the existing migrateJsonToSqlite — a copied JSON file still gets imported into a fresh SQLite db.
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.
Problem
The default data directory was package-relative (
<package-root>/data/), which causes two failure modes:EACCES on root-owned globals —
sudo npm install -g sideshowputs the package under/usr/lib/node_modules/(root-owned). Even after fix: create sqlite db parent directory before opening #157'smkdirSyncguard (which fixed the ENOENT case for user-owned installs), the mkdir itself throwsEACCESagainst a read-only parent. The server still crashes.Data wiped on reinstall — data under
node_modules/sideshow/data/is deleted bynpm install -gon upgrade. A user who runssideshowfor weeks, upgrades, and loses their workspace gets no warning.Fix
Move the default data directory to
~/.sideshow/— user-owned, always writable, survives reinstalls.SIDESHOW_DATA/SIDESHOW_DBnow default to~/.sideshow/sideshow.{json,db}instead of<pkg>/data/sideshow.{json,db}sideshow.{db,db-wal,db-shm,json}from the old<pkg>/data/to~/.sideshow/on first boot (only when using default paths)renameSyncwith anEXDEV→cpSyncfallback for cross-filesystem moves, and leaves old files in place as a backupmigrateJsonToSqlite: a copied JSON file still gets imported into a fresh SQLite db at the new locationVerification
test/migrateDataDir.test.ts(migrate all files, idempotent, no-op on missing old dir, no-op on no sideshow files, leaves unrelated files, partial new dir)npm run typecheck,npm run lint,npm run format:checkall cleanHOME→ migration ran (olddata/→~/.sideshow/), JSON→SQLite import ran, server started; second boot was idempotent (no migration log)Files
server/migrateDataDir.ts—migrateLegacyDataDir(oldDir, newDir): one-time file migrationserver/index.ts— new~/.sideshow/defaults + migration call (guarded by!SIDESHOW_DATA && !SIDESHOW_DB)test/migrateDataDir.test.ts— 6 tests.changeset/sideshow-data-home.md—patchCloses #160.