mirror of https://github.com/go-gitea/gitea.git
Copy git data from disk when restore repository (#16066)
parent
a38f62ad0f
commit
7979c3654e
|
@ -276,19 +276,22 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
||||||
// asset.DownloadURL maybe a local file
|
// asset.DownloadURL maybe a local file
|
||||||
var rc io.ReadCloser
|
var rc io.ReadCloser
|
||||||
var err error
|
var err error
|
||||||
if asset.DownloadURL == nil {
|
if asset.DownloadFunc != nil {
|
||||||
rc, err = asset.DownloadFunc()
|
rc, err = asset.DownloadFunc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else if asset.DownloadURL != nil {
|
||||||
rc, err = uri.Open(*asset.DownloadURL)
|
rc, err = uri.Open(*asset.DownloadURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer rc.Close()
|
if rc == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
_, err = storage.Attachments.Save(attach.RelativePath(), rc, int64(*asset.Size))
|
_, err = storage.Attachments.Save(attach.RelativePath(), rc, int64(*asset.Size))
|
||||||
|
rc.Close()
|
||||||
return err
|
return err
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -184,7 +184,7 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Trace("migrating git data")
|
log.Trace("migrating git data from %s", repo.CloneURL)
|
||||||
if err = uploader.CreateRepo(repo, opts); err != nil {
|
if err = uploader.CreateRepo(repo, opts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error) {
|
||||||
IsPrivate: isPrivate,
|
IsPrivate: isPrivate,
|
||||||
Description: opts["description"],
|
Description: opts["description"],
|
||||||
OriginalURL: opts["original_url"],
|
OriginalURL: opts["original_url"],
|
||||||
CloneURL: opts["clone_addr"],
|
CloneURL: filepath.Join(r.baseDir, "git"),
|
||||||
DefaultBranch: opts["default_branch"],
|
DefaultBranch: opts["default_branch"],
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,9 @@ func (r *RepositoryRestorer) GetReleases() ([]*base.Release, error) {
|
||||||
}
|
}
|
||||||
for _, rel := range releases {
|
for _, rel := range releases {
|
||||||
for _, asset := range rel.Assets {
|
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
|
return releases, nil
|
||||||
|
|
Loading…
Reference in New Issue