aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-06-04 21:14:20 +0800
committerGitHub <noreply@github.com>2021-06-04 16:14:20 +0300
commit7979c3654eb91adce4fd9717d9ff891496a56ff3 (patch)
treeaf4acb97e40bed8b557b50670b52b721395794d0 /modules
parenta38f62ad0f7419bf7c2af957e65982522317a478 (diff)
downloadgitea-7979c3654eb91adce4fd9717d9ff891496a56ff3.tar.gz
gitea-7979c3654eb91adce4fd9717d9ff891496a56ff3.zip
Copy git data from disk when restore repository (#16066)
Diffstat (limited to 'modules')
-rw-r--r--modules/migrations/gitea_uploader.go9
-rw-r--r--modules/migrations/migrate.go2
-rw-r--r--modules/migrations/restore.go6
3 files changed, 11 insertions, 6 deletions
diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go
index 217acb00e2..2b18098b7f 100644
--- a/modules/migrations/gitea_uploader.go
+++ b/modules/migrations/gitea_uploader.go
@@ -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 {
diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go
index 2f8889e67b..7eff3a3576 100644
--- a/modules/migrations/migrate.go
+++ b/modules/migrations/migrate.go
@@ -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
}
diff --git a/modules/migrations/restore.go b/modules/migrations/restore.go
index 4e63df1429..5b44811d52 100644
--- a/modules/migrations/restore.go
+++ b/modules/migrations/restore.go
@@ -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
}
@@ -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