Skip to content

fix: honor Range and If-Match on LFS snapshot requests - #447

Merged
joshfriend merged 2 commits into
mainfrom
lfs-snapshot-conditional-range
Nov 11, 2026
Merged

joshfriend merged 2 commits into
mainfrom
lfs-snapshot-conditional-range

Conversation

@joshfriend

@joshfriend joshfriend commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The LFS snapshot handler ignored Range and the conditional headers unless the cache returned an *os.File, so S3-tier and backfilled responses always sent the full body and an interrupted download could not resume. Serve it through the cache's conditional and range handling, as the working-tree snapshot already does.

Ranged reads from the disk tier also go through sendfile now. The range wrapper hid the file from net/http, so both snapshot handlers copied resumed downloads through userspace.

The LFS snapshot handler ignored the request's Range and validators unless
the cache handed back an *os.File, so an interrupted download could not
resume and had to start over. Serve it through the cache's conditional and
range handling like the working-tree snapshot.
@joshfriend
joshfriend marked this pull request as ready for review November 11, 2026 16:47
@joshfriend
joshfriend requested a review from a team as a code owner November 11, 2026 16:48
@joshfriend
joshfriend requested review from inez and removed request for a team November 11, 2026 16:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T16:58:02.916032Z 4913974 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@joshfriend joshfriend changed the title fix: honour Range and If-Match on LFS snapshot requests fix: honor Range and If-Match on LFS snapshot requests Nov 11, 2026
Disk wraps a ranged file in limitedReadCloser, which hid the file from
net/http's sendfile path, so resumed downloads were copied through
userspace. Hand ReadFrom the underlying LimitedReader instead.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4913974f22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +156 to +157
// TestDiskRangeReachesSendfile verifies a ranged disk read reaches ReadFrom as
// an *io.LimitedReader over the file, the only shape net's sendfile accepts.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the documentation comment on the top-level test

The new comment on TestDiskRangeReachesSendfile violates the root AGENTS.md instruction, which explicitly prohibits comments on top-level tests. Remove this test documentation comment to comply with the repository's commenting convention.

AGENTS.md reference: AGENTS.md:L21-L22

Useful? React with 👍 / 👎.

@joshfriend
joshfriend merged commit e724f8b into main Nov 11, 2026
8 checks passed
@joshfriend
joshfriend deleted the lfs-snapshot-conditional-range branch November 11, 2026 17:10
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