mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
fix(lfs): send the default branch as ref in batch download requests (#39891)
Fixes https://github.com/go-gitea/gitea/issues/38085 --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
1 parent
a6bc03cce1
commit
b5e53210c2
5 files changed
+23
-16
No files matched your search
@@ -67,8 +67,13 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
|
||||
errChan <- lfs.SearchPointerBlobs(ctx, gitRepo, pointerChan)
|
||||
}()
|
||||
|
||||
// some servers require `ref`, send the default branch for objects from all refs like
|
||||
// `git lfs fetch --all` does on the main branch: it uses current branch as `ref`:
|
||||
// https://github.com/git-lfs/git-lfs/blob/58a763d09d5fe4b7ea85c89ec799d71c5b0dc1da/commands/commands.go#L124-L137
|
||||
// `man git-lfs-fetch` said that "--all" can fetch all objects, so the default branch should work
|
||||
ref := git.RefNameFromBranch(repo.DefaultBranch).String()
|
||||
downloadObjects := func(pointers []lfs.Pointer) error {
|
||||
err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
|
||||
err := lfsClient.Download(ctx, ref, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
|
||||
if errors.Is(objectError, lfs.ErrObjectNotExist) {
|
||||
log.Warn("Ignoring missing upstream LFS object %-v: %v", p, objectError)
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user