diff --git a/modules/git/commit_archive.go b/modules/git/commit_archive.go index c7d1d06c468..d075ba09115 100644 --- a/modules/git/commit_archive.go +++ b/modules/git/commit_archive.go @@ -6,6 +6,7 @@ package git import ( + "context" "fmt" "path/filepath" "strings" @@ -39,7 +40,7 @@ type CreateArchiveOpts struct { } // CreateArchive create archive content to the target path -func (c *Commit) CreateArchive(target string, opts CreateArchiveOpts) error { +func (c *Commit) CreateArchive(ctx context.Context, target string, opts CreateArchiveOpts) error { if opts.Format.String() == "unknown" { return fmt.Errorf("unknown format: %v", opts.Format) } @@ -58,6 +59,6 @@ func (c *Commit) CreateArchive(target string, opts CreateArchiveOpts) error { c.ID.String(), ) - _, err := NewCommand(args...).RunInDir(c.repo.Path) + _, err := NewCommandContext(ctx, args...).RunInDir(c.repo.Path) return err } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 71df2d0cb75..5fc081a6f61 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -524,7 +524,7 @@ func Download(ctx *context.Context) { archivePath = path.Join(archivePath, base.ShortSha(commit.ID.String())+ext) if !com.IsFile(archivePath) { - if err := commit.CreateArchive(archivePath, git.CreateArchiveOpts{ + if err := commit.CreateArchive(ctx.Req.Context(), archivePath, git.CreateArchiveOpts{ Format: archiveType, Prefix: setting.Repository.PrefixArchiveFiles, }); err != nil {