File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 88 "context"
99 "fmt"
1010 "io"
11+ "net/http"
1112 "os"
1213 "path/filepath"
1314 "strconv"
@@ -554,11 +555,18 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
554555
555556 // SECURITY: We will assume that the pr.PatchURL has been checked
556557 // pr.PatchURL maybe a local file - but note EnsureSafe should be asserting that this safe
557- ret , err := uri .Open (pr .PatchURL ) // TODO: This probably needs to use the downloader as there may be rate limiting issues here
558+ httpClient := NewMigrationHTTPClient ()
559+
560+ req , err := http .NewRequest ("GET" , pr .PatchURL , nil )
561+ if err != nil {
562+ return err
563+ }
564+ req = req .WithContext (g .ctx )
565+ resp , err := httpClient .Do (req )
558566 if err != nil {
559567 return err
560568 }
561- defer ret .Close ()
569+ defer resp . Body .Close ()
562570
563571 pullDir := filepath .Join (g .repo .RepoPath (), "pulls" )
564572 if err = os .MkdirAll (pullDir , os .ModePerm ); err != nil {
@@ -572,7 +580,7 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
572580 defer f .Close ()
573581
574582 // TODO: Should there be limits on the size of this file?
575- _ , err = io .Copy (f , ret )
583+ _ , err = io .Copy (f , resp . Body )
576584
577585 return err
578586 }()
You can’t perform that action at this time.
0 commit comments