Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: preserve database authority against case-variant snapshot entries (#10064)
[._.]/ Adam Eivybde99af34b7c
diff --git a/server/services/backup.js b/server/services/backup.jsindex 221ea502d9..790007ccd8 100644--- a/server/services/backup.js+++ b/server/services/backup.js@@ -1321,8 +1321,12 @@ const OS_METADATA_RSYNC_EXCLUDES = [...OS_METADATA_FILES, '._*'].map(name => `--* verification and execution cannot disagree.*/const RESTORE_PRESERVED_FILES = Object.freeze(['database-authority.json']);-const RESTORE_PRESERVED_RSYNC_EXCLUDES = RESTORE_PRESERVED_FILES.map(name => `--exclude=/${name}`);-const isRestorePreservedPath = (relativePath) => RESTORE_PRESERVED_FILES.includes(relativePath);+// Matched case-insensitively (rsync has no such flag, so each letter becomes a+// `[xX]` class): on a case-insensitive volume a `Database-Authority.json` entry+// would otherwise overwrite the destination's lowercase record.+const caseInsensitiveGlob = (name) => name.replace(/[a-z]/gi, ch => `[${ch.toLowerCase()}${ch.toUpperCase()}]`);+const RESTORE_PRESERVED_RSYNC_EXCLUDES = RESTORE_PRESERVED_FILES.map(name => `--exclude=/${caseInsensitiveGlob(name)}`);+const isRestorePreservedPath = (relativePath) => RESTORE_PRESERVED_FILES.includes(relativePath.toLowerCase());// A filter naming a preserved file would otherwise be a silent no-op restore.// Compared case-insensitively after dropping empty/`.` segments, sodiff --git a/server/services/backup.test.js b/server/services/backup.test.jsindex d1f99f907e..c2a04c5fe2 100644--- a/server/services/backup.test.js+++ b/server/services/backup.test.js@@ -2392,6 +2392,22 @@ describe('restoreSnapshot manifest verification', () => {});});+ it('also keeps a mixed-case authority entry from replacing the destination record', async context => {+ await withRealRsync(context, async () => {+ await seedSnapshot();+ await writeSnapshotFile('Database-Authority.json', SNAPSHOT_AUTHORITY);+ await realFs.rm(joinPath(snapshotDataDir, 'database-authority.json'));+ await writeManifest({ [RECORD]: createHash('sha256').update('{"value":"snapshot"}').digest('hex') });+ await realFs.writeFile(authorityPath(), NEWER_LOCAL_AUTHORITY);++ await restoreSnapshot(tmpRoot, 'snap-1', { dryRun: false });++ expect(await realFs.readFile(authorityPath(), 'utf8')).toBe(NEWER_LOCAL_AUTHORITY);+ expect(await realFs.readFile(joinPath(PATHS.data, RECORD), 'utf8')).toBe('{"value":"snapshot"}');+ await realFs.rm(joinPath(PATHS.data, 'Database-Authority.json'), { force: true });+ });+ });+it('does not fail integrity for an authority file the restore never transfers', async () => {await seedSnapshot();await realFs.writeFile(joinPath(snapshotDataDir, 'database-authority.json'), 'edited after sealing');@@ -2964,7 +2980,7 @@ describe('restoreSnapshot snapshotId, filter flags, and settings re-sync', () =>'--exclude=desktop.ini','--exclude=._*',// Machine-local admission state is never installed by a restore (#10064).- '--exclude=/database-authority.json',+ '--exclude=/[dD][aA][tT][aA][bB][aA][sS][eE]-[aA][uU][tT][hH][oO][rR][iI][tT][yY].[jJ][sS][oO][nN]','--dry-run',// Leading `/` is load-bearing: rsync matches an unanchored pattern// against the end of every path, so `brain/***` would also restore@@ -2990,7 +3006,7 @@ describe('restoreSnapshot snapshotId, filter flags, and settings re-sync', () =>'--exclude=Thumbs.db','--exclude=desktop.ini','--exclude=._*',- '--exclude=/database-authority.json',+ '--exclude=/[dD][aA][tT][aA][bB][aA][sS][eE]-[aA][uU][tT][hH][oO][rR][iI][tT][yY].[jJ][sS][oO][nN]',]);});