Opening a library deletes another process's download in progress #105

Closed
opened 2026-09-23 05:34:58 +02:00 by clawbot · 1 comment
Collaborator

Problem

When a library opens, it deletes every .quak-*.tmp file in the cache's originals/ and thumbnails/ directories (src/library/content.ts:656-668). It does this even when another process is still writing that file. The download writer's temporary names carry no process ID (src/download/index.ts:205). The README allows several processes on one cache ("no lock file").

Example: quak backup runs for hours. Meanwhile quak get 123 in another terminal opens the same default cache and deletes the backup's partly written download. The backup's rename then fails with ENOENT, and that file is recorded as failed for the run. The backup tree already avoids this for its own temporary files by putting the process ID in the name and deleting only those whose process has exited (src/backup.ts:163-212).

Definition of done

  1. The download writer's temporary names carry the process ID, and the cache deletes a leftover only when its process is no longer running. Use the same rule as removeLeftoverTempFiles in src/backup.ts, shared rather than copied.
  2. The README backup-layout paragraph that names the temporary files is updated.
  3. Tests: a temporary file carrying a live process ID survives open(), and one carrying a process ID that has exited is removed.
  4. make check green; TODO.md updated in the same commit.

Model: opus-5-5

## Problem When a library opens, it deletes every `.quak-*.tmp` file in the cache's `originals/` and `thumbnails/` directories (`src/library/content.ts:656-668`). It does this even when another process is still writing that file. The download writer's temporary names carry no process ID (`src/download/index.ts:205`). The README allows several processes on one cache ("no lock file"). Example: `quak backup` runs for hours. Meanwhile `quak get 123` in another terminal opens the same default cache and deletes the backup's partly written download. The backup's rename then fails with `ENOENT`, and that file is recorded as failed for the run. The backup tree already avoids this for its own temporary files by putting the process ID in the name and deleting only those whose process has exited (`src/backup.ts:163-212`). ## Definition of done 1. The download writer's temporary names carry the process ID, and the cache deletes a leftover only when its process is no longer running. Use the same rule as `removeLeftoverTempFiles` in `src/backup.ts`, shared rather than copied. 2. The README backup-layout paragraph that names the temporary files is updated. 3. Tests: a temporary file carrying a live process ID survives `open()`, and one carrying a process ID that has exited is removed. 4. `make check` green; `TODO.md` updated in the same commit. Model: opus-5-5
clawbot self-assigned this 2026-09-23 05:34:58 +02:00
Author
Collaborator

Implemented in #120: the download writer's temp names carry the process ID, and the cache and the backup share one rule that deletes a temp file only when its process has exited.

Model: opus-5-5

Implemented in https://git.eeqj.de/sneak/quak/pulls/120: the download writer's temp names carry the process ID, and the cache and the backup share one rule that deletes a temp file only when its process has exited. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/quak#105