summaryrefslogtreecommitdiffstats
path: root/modules/migrations
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2019-12-11 00:09:06 -0600
committerLunny Xiao <xiaolunwen@gmail.com>2019-12-11 14:09:06 +0800
commit3bf5a07537a53c6903b39268559c5c76bee85c12 (patch)
tree0cd1f7602c09f4bf919a7fe87be84829bc5197c3 /modules/migrations
parentc3d31e55346329a221cc0ae37d89d1fba11ea737 (diff)
downloadgitea-3bf5a07537a53c6903b39268559c5c76bee85c12.tar.gz
gitea-3bf5a07537a53c6903b39268559c5c76bee85c12.zip
Only sync tags after all batches (#9319)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'modules/migrations')
-rw-r--r--modules/migrations/base/uploader.go2
-rw-r--r--modules/migrations/gitea.go10
-rw-r--r--modules/migrations/migrate.go10
3 files changed, 15 insertions, 7 deletions
diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go
index ae1be84b88..7d35d136a1 100644
--- a/modules/migrations/base/uploader.go
+++ b/modules/migrations/base/uploader.go
@@ -11,7 +11,7 @@ type Uploader interface {
CreateRepo(repo *Repository, opts MigrateOptions) error
CreateTopics(topic ...string) error
CreateMilestones(milestones ...*Milestone) error
- CreateReleases(releases ...*Release) error
+ CreateReleases(syncTags bool, releases ...*Release) error
CreateLabels(labels ...*Label) error
CreateIssues(issues ...*Issue) error
CreateComments(comments ...*Comment) error
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go
index 81a6116a23..617561194d 100644
--- a/modules/migrations/gitea.go
+++ b/modules/migrations/gitea.go
@@ -201,7 +201,7 @@ func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
}
// CreateReleases creates releases
-func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
+func (g *GiteaLocalUploader) CreateReleases(syncTags bool, releases ...*base.Release) error {
var rels = make([]*models.Release, 0, len(releases))
for _, release := range releases {
var rel = models.Release{
@@ -292,8 +292,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
return err
}
- // sync tags to releases in database
- return models.SyncReleasesWithTags(g.repo, g.gitRepo)
+ if syncTags {
+ // sync tags to releases in database
+ return models.SyncReleasesWithTags(g.repo, g.gitRepo)
+ }
+
+ return nil
}
// CreateIssues creates issues
diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go
index cfaedf78e3..124ef4413f 100644
--- a/modules/migrations/migrate.go
+++ b/modules/migrations/migrate.go
@@ -161,12 +161,16 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
}
relBatchSize := uploader.MaxBatchInsertSize("release")
+ syncTags := false
for len(releases) > 0 {
- if len(releases) < relBatchSize {
- relBatchSize = len(releases)
+ if len(releases) <= relBatchSize {
+ if len(releases) < relBatchSize {
+ relBatchSize = len(releases)
+ }
+ syncTags = true
}
- if err := uploader.CreateReleases(releases[:relBatchSize]...); err != nil {
+ if err := uploader.CreateReleases(syncTags, releases[:relBatchSize]...); err != nil {
return err
}
releases = releases[relBatchSize:]