Skip to content

Commit eb8f1cd

Browse files
committed
Respect settings during PR migration from API (how did this ever work?)
1 parent 4a6b37f commit eb8f1cd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

services/migrations/gitea_uploader.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
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
}()

0 commit comments

Comments
 (0)