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: keep rsync talking during a --checksum restore scan so the watchdog can't kill it (#7299)
[._.]/ Adam Eivy5a92f5b81567
diff --git a/server/services/backup.js b/server/services/backup.jsindex c37e245943..b45d1b381e 100644--- a/server/services/backup.js+++ b/server/services/backup.js@@ -351,6 +351,9 @@ function runRsync(srcDir, destDir, flags = []) {// `--itemize-changes` emits only after each file finishes. `--progress` is// also supported by macOS's bundled rsync 2.6.9 and emits within a large// file, giving the idle watchdog evidence that a slow transfer is healthy.+ // Both report only TRANSFERRING files, so a caller that adds `--checksum`+ // must also pass `-ii` or its scan of an unchanged tree is silent for the+ // whole digest and the watchdog kills it — see restoreSnapshot.const args = ['--archive', '--itemize-changes', '--progress', ...flags, srcDir + '/', destDir];const proc = spawn(resolveRsyncBinary(), args, { shell: false });@@ -1171,11 +1174,29 @@ export async function restoreSnapshot(destPath, snapshotId, { dryRun = true, sub// Restore must compare destination bytes even when size and mtime match.// Rsync's default quick-check would otherwise report a successful no-op for// equal-length edits that retain the snapshot timestamp.+ //+ // `-ii` is what keeps that affordable. `--checksum` makes rsync digest BOTH+ // copies of every file in scope, and a file that turns out to match emits+ // nothing under plain `--itemize-changes`/`--progress` — those report only+ // transferring files. A preview of a large unchanged tree therefore runs+ // silent for as long as the digest takes, and runRsync's idle watchdog+ // (BACKUP_PROCESS_IDLE_TIMEOUT_MS) SIGKILLs a perfectly healthy restore.+ // Doubling itemize makes rsync report unchanged entries too (`.f <path>`),+ // one line per file digested, which is what keeps the watchdog fed. The+ // changed-file count runRsync returns is unaffected: the added lines start+ // with `.`, and runRsync collects only `>`/`<` transfer lines.+ //+ // It must be the SHORT `-ii`, and it is deliberately not `--info=progress2`:+ // macOS ships openrsync, where the long `--itemize-changes` does NOT stack+ // when repeated and `--info=progress2` is rejected outright as an unknown+ // option (it arrived in rsync 3.1). `-ii` behaves identically on openrsync+ // and rsync 3.x, so no version probe is needed. See issue #7299.+ //// Before the include chain below: rsync takes the FIRST matching rule, so an// exclude placed after `--include=/<filter>/***` would never be consulted.// These are the files `snapshotManifestFilePaths` skips — keeping the two in// step is what preserves "everything transferred was verified".- const flags = ['--itemize-changes', '--checksum', ...OS_METADATA_RSYNC_EXCLUDES];+ const flags = ['-ii', '--checksum', ...OS_METADATA_RSYNC_EXCLUDES];if (dryRun) flags.push('--dry-run');if (subdirFilter) {// Anchored with a leading `/` — rsync matches an unanchored pattern againstdiff --git a/server/services/backup.test.js b/server/services/backup.test.jsindex b40a75063e..c1ca32d084 100644--- a/server/services/backup.test.js+++ b/server/services/backup.test.js@@ -1650,6 +1650,70 @@ describe('restoreSnapshot manifest verification', () => {spawn.mockReset();}});++ // #7299: `--checksum` makes rsync digest BOTH copies of every file in scope,+ // and `--itemize-changes`/`--progress` report only TRANSFERRING files. A file+ // that matches emitted nothing, so a preview of a large unchanged tree ran+ // silent for the whole digest, tripped runRsync's idle watchdog, and SIGKILLed+ // a perfectly healthy restore. `-ii` adds one unchanged-entry line per file+ // digested. The assertion is on rsync's own stdout for the exact vector+ // restoreSnapshot builds, paired with the pre-fix baseline (same vector, `-ii`+ // removed) so it discriminates rather than passing on any output at all.+ it('keeps real rsync emitting per file while checksumming an unchanged tree, without inflating the changed count', async context => {+ // Windows CI does not provision MSYS rsync. Unix coverage remains mandatory;+ // installed Windows rsync errors still fail this test rather than being hidden.+ if (process.platform === 'win32' && spawnSync('rsync', ['--version']).error?.code === 'ENOENT') {+ context.skip('Windows runner has no rsync executable; real rsync remains required on Linux/macOS.');+ return;+ }+ const unchangedPath = 'restore-watchdog/unchanged.json';+ const changedPath = 'restore-watchdog/changed.json';+ await writeManifest({+ [unchangedPath]: await writeSnapshotFile(unchangedPath, '{"value":"same"}'),+ [changedPath]: await writeSnapshotFile(changedPath, '{"value":"old"}'),+ });++ // Equal length AND identical mtime on both sides: rsync's quick check sees+ // no difference for either file, so only `--checksum` can tell them apart —+ // the very condition that makes the scan expensive and silent.+ const matchingMtime = new Date('2026-09-12T00:00:00.000Z');+ for (const [relativePath, liveContent] of [[unchangedPath, '{"value":"same"}'], [changedPath, '{"value":"new"}']]) {+ const livePath = joinPath(PATHS.data, relativePath);+ await realFs.mkdir(joinPath(livePath, '..'), { recursive: true });+ await realFs.writeFile(livePath, liveContent);+ await realFs.utimes(joinPath(snapshotDataDir, relativePath), matchingMtime, matchingMtime);+ await realFs.utimes(livePath, matchingMtime, matchingMtime);+ }++ const previousRsync = process.env.PORTOS_RSYNC;+ delete process.env.PORTOS_RSYNC;+ spawn.mockImplementation((...args) => spawnChild(...args));++ try {+ const preview = await restoreSnapshot(tmpRoot, 'snap-1', { dryRun: true });++ // The extra `-ii` lines describe unchanged entries and start with `.`,+ // so runRsync's `>`/`<` collector must be blind to them: the reported+ // count stays exactly the files that really differ.+ expect(preview.changedFiles.some(line => line.includes(changedPath))).toBe(true);+ expect(preview.changedFiles.some(line => line.includes(unchangedPath))).toBe(false);++ const args = spawn.mock.calls[0][1];+ expect(args).toContain('-ii');+ expect(args).toContain('--checksum');++ // Replay the exact vector. `-ii` must be the SHORT form: macOS ships+ // openrsync, where a repeated long `--itemize-changes` does not stack.+ const stdoutFor = vector => spawnSync(resolveRsyncBinary(), vector, { encoding: 'utf8' }).stdout ?? '';+ expect(stdoutFor(args)).toContain(unchangedPath);+ expect(stdoutFor(args.filter(arg => arg !== '-ii'))).not.toContain(unchangedPath);+ } finally {+ if (previousRsync === undefined) delete process.env.PORTOS_RSYNC;+ else process.env.PORTOS_RSYNC = previousRsync;+ spawn.mockReset();+ await realFs.rm(joinPath(PATHS.data, 'restore-watchdog'), { recursive: true, force: true });+ }+ });});// restoreSnapshot's service-side subdirFilter guard (issue #1822). These reject@@ -2007,14 +2071,18 @@ describe('restoreSnapshot snapshotId, filter flags, and settings re-sync', () =>// Asserted as an exact array (not arrayContaining): the ORDER matters to// rsync — `--exclude=*` must come last, after both includes, or the// targeted restore silently degrades into a full-tree restore.- // `--itemize-changes` legitimately appears twice: runRsync always prepends- // it, and restoreSnapshot seeds its own flag list with it. Harmless to- // rsync, and pinned here so a future de-dup is a deliberate change.+ // Itemize legitimately appears twice: runRsync always prepends the long+ // `--itemize-changes`, and restoreSnapshot adds the SHORT `-ii` so rsync+ // also reports files its `--checksum` digest found unchanged (#7299) —+ // without those lines a big unchanged tree is silent long enough to trip+ // the idle watchdog. The short form is load-bearing: macOS's openrsync+ // does not stack a repeated long `--itemize-changes`. Pinned here so a+ // future de-dup is a deliberate change.expect(spawn.mock.calls[0][1]).toEqual(['--archive','--itemize-changes','--progress',- '--itemize-changes',+ '-ii','--checksum',// OS metadata excludes come BEFORE the includes — rsync takes the first// matching rule — and mirror what the integrity inventory skips.