1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-06 17:40:57 +00:00

add files

This commit is contained in:
pat-s 2025-06-25 22:33:30 +02:00
parent 7ab27a7a7f
commit faa2dcdfca
No known key found for this signature in database
GPG key ID: 3C6318841EF78925
20 changed files with 1484 additions and 98 deletions

View file

@ -11,6 +11,7 @@ import (
"strings"
"time"
"forgejo.org/modules/httplib"
"forgejo.org/modules/log"
base "forgejo.org/modules/migration"
"forgejo.org/modules/proxy"
@ -101,27 +102,42 @@ func NewGogsDownloader(ctx context.Context, baseURL, userName, password, token,
downloader := GogsDownloader{
ctx: ctx,
baseURL: baseURL,
userName: userName,
password: password,
repoOwner: repoOwner,
repoName: repoName,
userName: userName,
password: password,
}
// Use the new HTTP client pool for migration operations
baseClient := httplib.GetMigrationClient()
baseTransport := baseClient.Transport.(*http.Transport)
var client *gogs.Client
if len(token) != 0 {
if len(token) > 0 {
client = gogs.NewClient(baseURL, token)
downloader.userName = token
} else {
transport := NewMigrationHTTPTransport()
transport.Proxy = func(req *http.Request) (*url.URL, error) {
req.SetBasicAuth(userName, password)
return proxy.Proxy()(req)
// Create custom transport with basic auth
migrationTransport := &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
req.SetBasicAuth(userName, password)
return proxy.Proxy()(req)
},
DialContext: baseTransport.DialContext,
ForceAttemptHTTP2: baseTransport.ForceAttemptHTTP2,
MaxIdleConns: baseTransport.MaxIdleConns,
MaxIdleConnsPerHost: baseTransport.MaxIdleConnsPerHost,
IdleConnTimeout: baseTransport.IdleConnTimeout,
TLSHandshakeTimeout: baseTransport.TLSHandshakeTimeout,
ExpectContinueTimeout: baseTransport.ExpectContinueTimeout,
DisableKeepAlives: baseTransport.DisableKeepAlives,
TLSClientConfig: baseTransport.TLSClientConfig,
}
downloader.transport = transport
downloader.transport = migrationTransport
client = gogs.NewClient(baseURL, "")
client.SetHTTPClient(&http.Client{
Transport: &downloader,
Timeout: baseClient.Timeout,
})
}