Skip to content

Commit

Permalink
Merge branch 'main' into feature-svg-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks authored Jun 4, 2021
2 parents 0264265 + 7979c36 commit 221e7e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions modules/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,22 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
// asset.DownloadURL maybe a local file
var rc io.ReadCloser
var err error
if asset.DownloadURL == nil {
if asset.DownloadFunc != nil {
rc, err = asset.DownloadFunc()
if err != nil {
return err
}
} else {
} else if asset.DownloadURL != nil {
rc, err = uri.Open(*asset.DownloadURL)
if err != nil {
return err
}
}
defer rc.Close()
if rc == nil {
return nil
}
_, err = storage.Attachments.Save(attach.RelativePath(), rc, int64(*asset.Size))
rc.Close()
return err
}()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion modules/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
return err
}

log.Trace("migrating git data")
log.Trace("migrating git data from %s", repo.CloneURL)
if err = uploader.CreateRepo(repo, opts); err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions modules/migrations/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error) {
IsPrivate: isPrivate,
Description: opts["description"],
OriginalURL: opts["original_url"],
CloneURL: opts["clone_addr"],
CloneURL: filepath.Join(r.baseDir, "git"),
DefaultBranch: opts["default_branch"],
}, nil
}
Expand Down Expand Up @@ -155,7 +155,9 @@ func (r *RepositoryRestorer) GetReleases() ([]*base.Release, error) {
}
for _, rel := range releases {
for _, asset := range rel.Assets {
*asset.DownloadURL = "file://" + filepath.Join(r.baseDir, *asset.DownloadURL)
if asset.DownloadURL != nil {
*asset.DownloadURL = "file://" + filepath.Join(r.baseDir, *asset.DownloadURL)
}
}
}
return releases, nil
Expand Down

0 comments on commit 221e7e8

Please sign in to comment.