An album whose folder cannot be made stops the run before the other albums and before failures.json is saved #197

Open
opened 2026-10-14 09:29:21 +02:00 by clawbot · 0 comments
Collaborator

Severity: medium

Where: the per-album loop at the end of runLockedBackup in src/backup.ts: mkdirSync(colDir, ...) and writeAlbumJSON(...) run outside any try, unlike the symlink work beside them (rebuildSymlink, removeStaleLinks, removeStaleAlbumDirs), which is caught and logged.

Problem: an album name the server sends can make either call throw, and the throw ends the run with quak: ENAMETOOLONG: ... or quak: EEXIST: ... and exit 1. Every original is stored by then, but the album folders from that album on are not rebuilt, and failures.json is never written, so the failures this run did record (a 404, say) are lost and their attempt counts never advance. The same happens on every later run, so for such an account the album folders and the ledger never work. Two names do it:

  • an album name over 255 bytes, which the file system refuses as a folder name;
  • an album named x.json beside an album named x: the folder collections/x.json/ and the JSON file collections/x.json are the same path.

The README says each run rebuilds the album folders and removes stale links, and that per-file errors are logged and the run continues.

Reproduced: two backups through the fake Ente server of test/ente-server.ts. Albums x (one file) and x.json (one file): exit 1, quak: EEXIST: file already exists, mkdir '.../collections/x.json', both originals at their save paths, the same again on the second run. An album named with 300 Ls (one file) before an album ok whose file always answers 404: FAILED original b.jpg: HTTP 404 is printed, then quak: ENAMETOOLONG: name too long, mkdir '.../collections/LLL...', exit 1, no failures.json and no collections/ok.json.

Done when: a failure to make or write one album's folder or JSON is logged on one line naming the album, counted as a failure (the run exits 1), and the other albums and failures.json are still written; a folder name that would clash with another album's JSON name, or exceed the name length the file system allows, gets the album's ID added, as two albums with one name do (README, "Backup layout"). Tests in test/cli/backup.test.ts or test/cli/backup-end-to-end.test.ts cover both names and check the ledger and the later album's folder.

Model: fable-5-1

Severity: medium **Where:** the per-album loop at the end of `runLockedBackup` in `src/backup.ts`: `mkdirSync(colDir, ...)` and `writeAlbumJSON(...)` run outside any `try`, unlike the symlink work beside them (`rebuildSymlink`, `removeStaleLinks`, `removeStaleAlbumDirs`), which is caught and logged. **Problem:** an album name the server sends can make either call throw, and the throw ends the run with `quak: ENAMETOOLONG: ...` or `quak: EEXIST: ...` and exit 1. Every original is stored by then, but the album folders from that album on are not rebuilt, and `failures.json` is never written, so the failures this run did record (a 404, say) are lost and their attempt counts never advance. The same happens on every later run, so for such an account the album folders and the ledger never work. Two names do it: - an album name over 255 bytes, which the file system refuses as a folder name; - an album named `x.json` beside an album named `x`: the folder `collections/x.json/` and the JSON file `collections/x.json` are the same path. The README says each run rebuilds the album folders and removes stale links, and that per-file errors are logged and the run continues. **Reproduced:** two backups through the fake Ente server of `test/ente-server.ts`. Albums `x` (one file) and `x.json` (one file): exit 1, `quak: EEXIST: file already exists, mkdir '.../collections/x.json'`, both originals at their save paths, the same again on the second run. An album named with 300 `L`s (one file) before an album `ok` whose file always answers 404: `FAILED original b.jpg: HTTP 404` is printed, then `quak: ENAMETOOLONG: name too long, mkdir '.../collections/LLL...'`, exit 1, no `failures.json` and no `collections/ok.json`. **Done when:** a failure to make or write one album's folder or JSON is logged on one line naming the album, counted as a failure (the run exits 1), and the other albums and `failures.json` are still written; a folder name that would clash with another album's JSON name, or exceed the name length the file system allows, gets the album's ID added, as two albums with one name do (README, "Backup layout"). Tests in `test/cli/backup.test.ts` or `test/cli/backup-end-to-end.test.ts` cover both names and check the ledger and the later album's folder. Model: fable-5-1
clawbot added this to the 1.0.0 milestone 2026-10-14 09:29:21 +02:00
Sign in to join this conversation.