Keep another process's downloads when opening a library (closes #105) #120

Merged
clawbot merged 1 commits from issue-105-temp-reaping into next2 2026-09-23 07:25:29 +02:00
Collaborator

Fixes #105.

Opening a library deleted every .quak-*.tmp file in the cache's originals/ and thumbnails/, including a download another process (for example a long quak backup) was still writing, whose rename then failed.

  • The download writer now names its temp files .quak-<pid>-<random>.tmp.
  • removeLeftoverTempFiles moved from src/backup.ts into src/download/index.ts, next to the writer, and matches both the writer's names and the backup copy's .quak-backup-<name>-<pid>-<random>.tmp. It deletes a file only when the process ID in its name is not running. The backup and the cache's open() both call it.
  • The README backup-layout paragraph gives the new name and the rule.

Tests: the cache test puts temp files carrying this test's own process ID and an exited child's ID in both directories; open() keeps the first and removes the second. The writeAtomic test pins the process ID in the temp name.

Disclosures:

  • Judgement call: the backup run now also removes download-writer leftovers in its own originals/ and thumbnails/, since the rule is shared.
  • Temp files written before this change carry no process ID and are no longer removed automatically.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/quak/issues/105. Opening a library deleted every `.quak-*.tmp` file in the cache's `originals/` and `thumbnails/`, including a download another process (for example a long `quak backup`) was still writing, whose rename then failed. - The download writer now names its temp files `.quak-<pid>-<random>.tmp`. - `removeLeftoverTempFiles` moved from `src/backup.ts` into `src/download/index.ts`, next to the writer, and matches both the writer's names and the backup copy's `.quak-backup-<name>-<pid>-<random>.tmp`. It deletes a file only when the process ID in its name is not running. The backup and the cache's `open()` both call it. - The README backup-layout paragraph gives the new name and the rule. Tests: the cache test puts temp files carrying this test's own process ID and an exited child's ID in both directories; `open()` keeps the first and removes the second. The `writeAtomic` test pins the process ID in the temp name. Disclosures: - Judgement call: the backup run now also removes download-writer leftovers in its own `originals/` and `thumbnails/`, since the rule is shared. - Temp files written before this change carry no process ID and are no longer removed automatically. Model: opus-5-5
clawbot self-assigned this 2026-09-23 06:45:38 +02:00
clawbot added the needs-review label 2026-09-23 06:45:43 +02:00
Author
Collaborator

PASS on 9573724 rebased onto next2 cda57ee (TODO.md-only conflict, resolved locally).

Non-blocking note: the PR says temp files from before this change are no longer removed, but an old .quak-&lt;uuid&gt;.tmp whose last UUID group is all digits matches the new pattern in src/download/index.ts:209, and that group is read as a process ID, so some old leftovers are still removed. This is harmless because they are leftovers either way. Only the disclosure is inaccurate.

Model: opus-5-5

PASS on `9573724` rebased onto `next2` `cda57ee` (TODO.md-only conflict, resolved locally). Non-blocking note: the PR says temp files from before this change are no longer removed, but an old `.quak-&lt;uuid&gt;.tmp` whose last UUID group is all digits matches the new pattern in `src/download/index.ts:209`, and that group is read as a process ID, so some old leftovers are still removed. This is harmless because they are leftovers either way. Only the disclosure is inaccurate. Model: opus-5-5
clawbot added 1 commit 2026-09-23 07:19:13 +02:00
The download writer's temp files are now named .quak-<pid>-<random>.tmp.
removeLeftoverTempFiles moves from the backup into the download module and
deletes a .quak-*.tmp file only when the process ID in its name is no
longer running; the content cache calls it at open() instead of deleting
every temp file, so a download in progress in another process sharing the
cache survives. The README backup layout and TODO.md are updated.

Model: opus-5-5
clawbot force-pushed issue-105-temp-reaping from 9573724a0f to c5dd63ef3a 2026-09-23 07:19:13 +02:00 Compare
clawbot merged commit fc396d1ecc into next2 2026-09-23 07:25:29 +02:00
clawbot deleted branch issue-105-temp-reaping 2026-09-23 07:25:29 +02:00
Sign in to join this conversation.