Remove the blob temp file when a backup stops part-way #347

Merged
clawbot merged 1 commits from issue-302-remove-blob-temp-file into next 2026-10-13 11:14:57 +02:00
Collaborator

Fixes #302.

What was wrong: when snapshot create stopped in phase 2 on a file error, a full temporary directory or Ctrl-C, the blob being packed was never finalized. The packer removes a blob's temp file only when it finalizes it, so the vaultik-blob-*.tmp file (up to blob_size_limit of encrypted data) stayed in $TMPDIR, one more for every such run.

What changed: the new Packer.DiscardCurrentBlob closes and removes the temp file of the blob in progress and drops that blob. Phase 2 (processPhase) defers it, so it runs however phase 2 ends; after a successful flush no blob is in progress and it does nothing. A test runs one backup that stops at a file it cannot read and one that is cancelled, and checks that no vaultik-blob-* file is left.

Judgement call: the blob's row in the local index is still left behind, as before; the next run's repair of interrupted blobs removes it, and the issue asks only about the temp file.

Deviation: no TODO.md entry, at the repo-manager's direction; those entries are written together in #334.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/302. **What was wrong:** when `snapshot create` stopped in phase 2 on a file error, a full temporary directory or Ctrl-C, the blob being packed was never finalized. The packer removes a blob's temp file only when it finalizes it, so the `vaultik-blob-*.tmp` file (up to `blob_size_limit` of encrypted data) stayed in `$TMPDIR`, one more for every such run. **What changed:** the new `Packer.DiscardCurrentBlob` closes and removes the temp file of the blob in progress and drops that blob. Phase 2 (`processPhase`) defers it, so it runs however phase 2 ends; after a successful flush no blob is in progress and it does nothing. A test runs one backup that stops at a file it cannot read and one that is cancelled, and checks that no `vaultik-blob-*` file is left. Judgement call: the blob's row in the local index is still left behind, as before; the next run's repair of interrupted blobs removes it, and the issue asks only about the temp file. Deviation: no TODO.md entry, at the repo-manager's direction; those entries are written together in https://git.eeqj.de/sneak/vaultik/issues/334. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 10:05:41 +02:00
clawbot self-assigned this 2026-10-13 10:05:42 +02:00
clawbot added 1 commit 2026-10-13 10:05:42 +02:00
When `snapshot create` stopped on a file error, a full temporary
directory or Ctrl-C, the blob being packed was never finalized, and its
`vaultik-blob-*.tmp` file (up to `blob_size_limit` of encrypted data)
stayed in `$TMPDIR`. Phase 2 now calls the new
`Packer.DiscardCurrentBlob` on the way out, which closes and removes
that file. After a successful flush no blob is in progress, so the call
then does nothing.

The blob's row in the local index is left, as before, for the next
run's repair of interrupted blobs to remove.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 0288735aaf into next 2026-10-13 11:14:57 +02:00
clawbot deleted branch issue-302-remove-blob-temp-file 2026-10-13 11:14:58 +02:00
Sign in to join this conversation.