Skip to content

PROD-2201: fix interrupted asset download poisoning the pull cache#174

Merged
5PK merged 3 commits into
mainfrom
PROD-2201-asset-download-cache-poison
Jul 8, 2026
Merged

PROD-2201: fix interrupted asset download poisoning the pull cache#174
5PK merged 3 commits into
mainfrom
PROD-2201-asset-download-cache-poison

Conversation

@5PK

@5PK 5PK commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

PROD-2201

When an asset pull is interrupted (or a single file download fails), the CLI wrote the asset's metadata JSON before the binary downloaded. Change detection then skipped the asset forever — it only checked the JSON's existence + dateModified, never the binary on disk — and later pushes failed with Local asset file not found.

Fix (src/lib/downloaders/download-assets.ts)

  1. Skip decision verifies the binary. shouldDownloadAsset now takes binaryExists; a present metadata JSON with a missing binary returns shouldDownload: true (reason: "missing binary"). This lets an already-poisoned cache self-heal on the next pull — no manual JSON deletion needed.
  2. Metadata written after the binary. exportFiles(...) for the metadata JSON now runs only inside the downloadFile success branch, so an interrupted run can no longer leave a metadata-only (poisoned) entry.

Tests

src/lib/downloaders/tests/download-assets.test.ts — 4 new cases:

  • unchanged metadata + missing binary → re-download
  • unchanged metadata + present binary → skip
  • downloadFile fails → metadata JSON not written
  • downloadFile succeeds → metadata written, and only after the download resolves

Full suite green (97 suites / 1689 tests).

🤖 Generated with Claude Code

5PK and others added 3 commits July 8, 2026 13:19
An interrupted asset pull wrote the metadata JSON before the binary
downloaded. Change detection then skipped the asset forever (it only
checked the JSON's existence + dateModified), and later pushes failed
with "Local asset file not found".

- shouldDownloadAsset now takes binaryExists; a present metadata JSON
  with a missing binary returns shouldDownload: true (reason: "missing
  binary"), so an already-poisoned cache self-heals on the next pull.
- Write the metadata JSON only after downloadFile succeeds, so an
  interrupted run can no longer leave a metadata-only (poisoned) entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Covers both halves of the fix:
- unchanged metadata + missing binary -> re-download; + present binary -> skip
- metadata JSON not written when downloadFile fails; written only after it resolves

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@5PK 5PK merged commit 1c6c6c6 into main Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants