@ -282,6 +282,8 @@ func (g *GiteaDownloader) convertGiteaRelease(rel *gitea_sdk.Release) *base.Rele
httpClient := NewMigrationHTTPClient ( )
httpClient := NewMigrationHTTPClient ( )
for _ , asset := range rel . Attachments {
for _ , asset := range rel . Attachments {
assetID := asset . ID // Don't optimize this, for closure we need a local variable
assetDownloadURL := asset . DownloadURL
size := int ( asset . Size )
size := int ( asset . Size )
dlCount := int ( asset . DownloadCount )
dlCount := int ( asset . DownloadCount )
r . Assets = append ( r . Assets , & base . ReleaseAsset {
r . Assets = append ( r . Assets , & base . ReleaseAsset {
@ -292,18 +294,18 @@ func (g *GiteaDownloader) convertGiteaRelease(rel *gitea_sdk.Release) *base.Rele
Created : asset . Created ,
Created : asset . Created ,
DownloadURL : & asset . DownloadURL ,
DownloadURL : & asset . DownloadURL ,
DownloadFunc : func ( ) ( io . ReadCloser , error ) {
DownloadFunc : func ( ) ( io . ReadCloser , error ) {
asset , _ , err := g . client . GetReleaseAttachment ( g . repoOwner , g . repoName , rel . ID , asset . ID)
asset , _ , err := g . client . GetReleaseAttachment ( g . repoOwner , g . repoName , rel . ID , asset ID)
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
if ! hasBaseURL ( asset . DownloadURL, g . baseURL ) {
if ! hasBaseURL ( asset DownloadURL, g . baseURL ) {
WarnAndNotice ( "Unexpected AssetURL for assetID[%d] in %s: %s" , asset . ID, g , asset . DownloadURL)
WarnAndNotice ( "Unexpected AssetURL for assetID[%d] in %s: %s" , asset ID, g , asset DownloadURL)
return io . NopCloser ( strings . NewReader ( asset . DownloadURL ) ) , nil
return io . NopCloser ( strings . NewReader ( asset . DownloadURL ) ) , nil
}
}
// FIXME: for a private download?
// FIXME: for a private download?
req , err := http . NewRequest ( "GET" , asset . DownloadURL, nil )
req , err := http . NewRequest ( "GET" , asset DownloadURL, nil )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}