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 8
8
"context"
9
9
"fmt"
10
10
"io"
11
+ "net/http"
11
12
"os"
12
13
"path/filepath"
13
14
"strconv"
@@ -554,11 +555,18 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
554
555
555
556
// SECURITY: We will assume that the pr.PatchURL has been checked
556
557
// 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 )
558
566
if err != nil {
559
567
return err
560
568
}
561
- defer ret .Close ()
569
+ defer resp . Body .Close ()
562
570
563
571
pullDir := filepath .Join (g .repo .RepoPath (), "pulls" )
564
572
if err = os .MkdirAll (pullDir , os .ModePerm ); err != nil {
@@ -572,7 +580,7 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
572
580
defer f .Close ()
573
581
574
582
// TODO: Should there be limits on the size of this file?
575
- _ , err = io .Copy (f , ret )
583
+ _ , err = io .Copy (f , resp . Body )
576
584
577
585
return err
578
586
}()
You can’t perform that action at this time.
0 commit comments