mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Set context for running CreateArchive in to that of the request (#12555)
Set the context for CreateArchive to that of the request to ensure that archives are only built for as long as a request is requesting them Fix #11551 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		@@ -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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user