Skip to content

fix(repo): avoid a repo-sized temp file for every bundle download - #38863

Merged
bircni merged 3 commits into
go-gitea:mainfrom
somaz94:fix/bundle-stream-no-temp-file
Aug 11, 2026
Merged

bircni merged 3 commits into
go-gitea:mainfrom
somaz94:fix/bundle-stream-no-temp-file

Conversation

@somaz94

@somaz94 somaz94 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Bundle downloads run git bundle create into a temp file under data/tmp/git-repo-content and copy it to the response, so every download puts a second, repo-sized copy on disk before the first byte is sent. If the process dies mid-request that copy is stranded: the startup sweep only drops files older than 3 days, and cannot remove a directory that still holds a newer file.

Streaming git bundle create - to the response removes that copy. CreateArchive above already uses the same gitcmd pattern, and the bundle bytes are unchanged (existing integration assertions on the exact length still pass).

One consequence: git can now fail after output starts, so a mid-stream failure truncates the body instead of returning an error.

I did not act on the TODO. A temp ref only works under refs/heads/*; with refs/bundle/temp-* the bundle carries no branch and clones empty, so I noted that on the TODO.

Fixes #38447

Assisted-by: Claude Code:claude-opus-5

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 11, 2026
@somaz94
somaz94 marked this pull request as ready for review August 11, 2026 06:54
@github-actions github-actions Bot added topic/repo Related to repositories type/bug labels Aug 11, 2026
Comment thread modules/git/archive.go Outdated
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 11, 2026
@wxiaoguang

This comment was marked as outdated.

@wxiaoguang
wxiaoguang marked this pull request as draft August 11, 2026 14:18
A refs/heads/* ref alone is not enough. Without a HEAD at the same
commit, a clone of the bundle gets no branch and no checkout, on git
2.13 through 2.55. The live repo cannot supply that HEAD, because its
own HEAD points at the default branch, so the temp repo has to stay.

Assisted-by: Claude Code:claude-opus-5
@wxiaoguang
wxiaoguang marked this pull request as ready for review August 11, 2026 15:02
@bircni
bircni enabled auto-merge (squash) August 11, 2026 16:02
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 11, 2026
@bircni bircni added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 11, 2026
@bircni
bircni merged commit 3580591 into go-gitea:main Aug 11, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 28.0.0 milestone Aug 11, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 11, 2026
silverwind added a commit to ToastyTheBot/gitea that referenced this pull request Aug 11, 2026
* origin/main: (22 commits)
  fix(repo): avoid a repo-sized temp file for every bundle download (go-gitea#38863)
  refactor: markup render (go-gitea#38864)
  fix(lfs): accept successful transfer responses (go-gitea#38866)
  chore: bump pnpm to v11 in nix flake (go-gitea#38856)
  refactor: api token scope check (go-gitea#38862)
  [skip ci] Updated translations via Crowdin
  fix(avatar): use sha256 and inline the federated avatar lookup (go-gitea#38843)
  enhance(actions): set ref_protected in context (go-gitea#38852)
  chore(deps): update dependencies (go-gitea#38851)
  chore: drop `make update*` targets (go-gitea#38845)
  refactor: form binding validation (go-gitea#38832)
  [skip ci] Updated translations via Crowdin
  enhance(ui): restyle toasts (go-gitea#38842)
  feat(packages): add support for uploading helm provenance files (go-gitea#36695)
  chore: rename migration package for next release to v28 (go-gitea#38844)
  refactor: replace `gliderlabs/ssh` with `golang.org/x/crypto/ssh` (go-gitea#38837)
  fix(gitdiff): render exact-limit diffs and zero-limit comments (go-gitea#38838)
  enhance: refine repo watching (go-gitea#38835)
  chore: enable `forcetypeassert` linter, fix issues (go-gitea#38804)
  ci: install tools for renovate post-upgrade tasks (go-gitea#38815)
  ...

# Conflicts:
#	modelmigration/migrations.go
#	modelmigration/v28/v348.go
#	modelmigration/v28/v348_test.go
#	routers/web/repo/setting/deploy_key.go
#	routers/web/repo/setting/settings_test.go
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 12, 2026
* 'main' of https://github.com/go-gitea/gitea: (43 commits)
  [skip ci] Updated translations via Crowdin
  fix(repo): avoid a repo-sized temp file for every bundle download (go-gitea#38863)
  refactor: markup render (go-gitea#38864)
  fix(lfs): accept successful transfer responses (go-gitea#38866)
  chore: bump pnpm to v11 in nix flake (go-gitea#38856)
  refactor: api token scope check (go-gitea#38862)
  [skip ci] Updated translations via Crowdin
  fix(avatar): use sha256 and inline the federated avatar lookup (go-gitea#38843)
  enhance(actions): set ref_protected in context (go-gitea#38852)
  chore(deps): update dependencies (go-gitea#38851)
  chore: drop `make update*` targets (go-gitea#38845)
  refactor: form binding validation (go-gitea#38832)
  [skip ci] Updated translations via Crowdin
  enhance(ui): restyle toasts (go-gitea#38842)
  feat(packages): add support for uploading helm provenance files (go-gitea#36695)
  chore: rename migration package for next release to v28 (go-gitea#38844)
  refactor: replace `gliderlabs/ssh` with `golang.org/x/crypto/ssh` (go-gitea#38837)
  fix(gitdiff): render exact-limit diffs and zero-limit comments (go-gitea#38838)
  enhance: refine repo watching (go-gitea#38835)
  chore: enable `forcetypeassert` linter, fix issues (go-gitea#38804)
  ...
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 12, 2026
* main: (43 commits)
  [skip ci] Updated translations via Crowdin
  fix(repo): avoid a repo-sized temp file for every bundle download (go-gitea#38863)
  refactor: markup render (go-gitea#38864)
  fix(lfs): accept successful transfer responses (go-gitea#38866)
  chore: bump pnpm to v11 in nix flake (go-gitea#38856)
  refactor: api token scope check (go-gitea#38862)
  [skip ci] Updated translations via Crowdin
  fix(avatar): use sha256 and inline the federated avatar lookup (go-gitea#38843)
  enhance(actions): set ref_protected in context (go-gitea#38852)
  chore(deps): update dependencies (go-gitea#38851)
  chore: drop `make update*` targets (go-gitea#38845)
  refactor: form binding validation (go-gitea#38832)
  [skip ci] Updated translations via Crowdin
  enhance(ui): restyle toasts (go-gitea#38842)
  feat(packages): add support for uploading helm provenance files (go-gitea#36695)
  chore: rename migration package for next release to v28 (go-gitea#38844)
  refactor: replace `gliderlabs/ssh` with `golang.org/x/crypto/ssh` (go-gitea#38837)
  fix(gitdiff): render exact-limit diffs and zero-limit comments (go-gitea#38838)
  enhance: refine repo watching (go-gitea#38835)
  chore: enable `forcetypeassert` linter, fix issues (go-gitea#38804)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/repo Related to repositories type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tmp/git-repo-content full of bundle files

5 participants