Skip to content

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

fix(backup): skip .DS_Store when listing snapshots

[._.]/ Adam Eivyfa5844b24bae
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f1415f42af..b2c9f926ca 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -47,6 +47,8 @@
## Fixed
+- **Backup: the snapshots list no longer chokes on `.DS_Store`** — when the backup target is an iCloud/Finder folder, macOS drops a `.DS_Store` file into every directory. The snapshot lister treated each directory entry as a snapshot id, so it tried to read `<.DS_Store>/manifest.json` and logged a repeating `ENOTDIR: not a directory` error (and `.DS_Store` showed up as a bogus, dateless row in the snapshots list). It now skips non-directory and dotfile entries, and a snapshot that predates manifests no longer logs a scary "failed to read" warning on every list.
+
- **Backup: the database dump now picks a `pg_dump` new enough for your server** — on machines with more than one PostgreSQL install (the common Homebrew case, where an older `postgresql@NN` keg shadows the running server in `PATH`), the backup ran an out-of-date `pg_dump` and failed with "server version mismatch" — leaving the backup degraded (files saved, database not). The backup now reads the live server's major version and selects a `pg_dump` at least that new from the installed Homebrew kegs / Postgres.app bundles (set `PORTOS_PGDUMP` to force a specific binary). When nothing new enough is installed, the failure is reported as a distinct `version_mismatch` with a Settings → Backup hint to install a newer `pg_dump`, instead of the generic "is pg_dump installed / is PG reachable" message; the exact `pg_dump` error is also available on hover.
- **Songs: "500 Miles" now ships the correct melody, in G major** — the built-in "500 Miles" previously carried a placeholder verse melody in C major that didn't match the song. It's been re-transcribed in G major (the Hedy West lead sheet — G · Em · C · Am7 · D7 · G) with the correct verse tune, chords, and rhythm. Fresh installs get it directly; an existing install that still holds the old placeholder is upgraded automatically on boot (a migration that only touches the unedited shipped version — a score you've customized is left alone), and you can always pull the latest via the song's "Refresh from template" button.
diff --git a/server/services/backup.js b/server/services/backup.js
index 58990531f5..b3861616e6 100644
--- a/server/services/backup.js
+++ b/server/services/backup.js
@@ -497,12 +497,20 @@ export async function listSnapshots(destPath) {
if (!destPath) return [];
const snapshotsDir = join(destPath, 'snapshots', MACHINE_HOST);
- const entries = await readdir(snapshotsDir).catch(() => []);
+ // withFileTypes so we can skip non-directory entries: the backup target is
+ // commonly an iCloud/Finder folder, where macOS drops a `.DS_Store` FILE into
+ // every directory. Treating it as a snapshot id and reading
+ // `<.DS_Store>/manifest.json` throws ENOTDIR. Also skip dotfile-named dirs so
+ // nothing hidden can masquerade as a snapshot (real ids are timestamps).
+ const entries = await readdir(snapshotsDir, { withFileTypes: true }).catch(() => []);
+ const ids = entries.filter(e => e.isDirectory() && !e.name.startsWith('.')).map(e => e.name);
const snapshots = await Promise.all(
- entries.map(async (id) => {
+ ids.map(async (id) => {
const manifestPath = join(snapshotsDir, id, 'manifest.json');
- const manifest = await readJSONFile(manifestPath, null);
+ // logError:false — a snapshot taken before manifests existed legitimately
+ // has none; the null is handled below, so it isn't worth a warning per list.
+ const manifest = await readJSONFile(manifestPath, null, { logError: false });
return {
id,
createdAt: manifest?.generatedAt ?? null,
diff --git a/server/services/backup.test.js b/server/services/backup.test.js
index 5d579a52d4..210e9274b4 100644
--- a/server/services/backup.test.js
+++ b/server/services/backup.test.js
@@ -48,7 +48,7 @@ vi.mock('fs/promises', async (importOriginal) => {
import { checkHealth, getServerMajorVersion } from '../lib/db.js';
import { getBackendName } from './memoryBackend.js';
import * as fs from 'fs/promises';
-import { DEFAULT_EXCLUDES, computeEffectiveExcludes, pickPgDump } from './backup.js';
+import { DEFAULT_EXCLUDES, computeEffectiveExcludes, pickPgDump, listSnapshots } from './backup.js';
// Helper: build a fake child process whose close/error we can drive.
function fakeProc() {
@@ -188,6 +188,37 @@ describe('pickPgDump', () => {
});
});
+describe('listSnapshots', () => {
+ beforeEach(() => vi.clearAllMocks());
+ const dirent = (name, isDir) => ({ name, isDirectory: () => isDir });
+
+ it('skips non-directory entries like .DS_Store (iCloud/Finder droppings)', async () => {
+ // The backup target is commonly an iCloud folder; macOS drops a `.DS_Store`
+ // FILE into every dir. It must not be treated as a snapshot id (reading
+ // `<.DS_Store>/manifest.json` would throw ENOTDIR).
+ vi.spyOn(fs, 'readdir').mockResolvedValue([
+ dirent('.DS_Store', false),
+ dirent('2026-06-08T15-18-34', true),
+ dirent('2026-06-07T09-00-00', true),
+ ]);
+ vi.spyOn(fs, 'readFile').mockImplementation(async (p) => {
+ if (String(p).includes('.DS_Store')) throw new Error('ENOTDIR — .DS_Store should never be read');
+ return JSON.stringify({ generatedAt: '2026-06-08T00:00:00Z', fileCount: 10 });
+ });
+ const result = await listSnapshots('/dest');
+ const ids = result.map(s => s.id);
+ expect(ids).toHaveLength(2);
+ expect(ids).toContain('2026-06-08T15-18-34');
+ expect(ids).not.toContain('.DS_Store');
+ });
+
+ it('returns [] for a falsy destPath without touching the filesystem', async () => {
+ const readdirSpy = vi.spyOn(fs, 'readdir');
+ expect(await listSnapshots('')).toEqual([]);
+ expect(readdirSpy).not.toHaveBeenCalled();
+ });
+});
+
describe('dumpPostgres status classification', () => {
let dumpPostgres;
beforeEach(async () => {