Skip to content

[Backport release-2.4] Don't cache truncated package downloads in xpkg - #1200

Merged
bobh66 merged 1 commit into
release-2.4from
backport-1189-to-release-2.4
Oct 15, 2026
Merged

bobh66 merged 1 commit into
release-2.4from
backport-1189-to-release-2.4

Conversation

@github-actions

Copy link
Copy Markdown

Description

Backport of #1189 to release-2.4.

CachedClient.Get copies the package stream into the package cache through a
pipe while it parses it. The parser closes its reader even when parsing fails,
and closing the tee reader closed the pipe cleanly. So when a download failed
partway, FsPackageCache.Store saw a normal EOF and cached a valid gzip that held
only a prefix of package.yaml. The next Get hit the cache, parsed the prefix
without error, and returned a package that was missing most of its objects.

Give the parser only the package content to close, and close the pipe with the
parse error once Parse returns, so Store fails instead of caching a prefix. Get
now waits for Store to finish before returning.

Also make Store write to a temporary file and rename it into place only after
the content has been written and synced, removing the temporary file on any
error. The cache then never holds a partially written package under its real
name.

Signed-off-by: ezgidemirel <ezgidemirel91@gmail.com>
(cherry picked from commit 6ccb301)
@github-actions
github-actions Bot requested a review from a team as a code owner October 13, 2026 14:20
@github-actions
github-actions Bot requested review from negz and removed request for a team October 13, 2026 14:20
@bobh66
bobh66 merged commit 9aad9da into release-2.4 Oct 15, 2026
9 checks passed
@bobh66
bobh66 deleted the backport-1189-to-release-2.4 branch October 15, 2026 15:44
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