summaryrefslogtreecommitdiffstats
path: root/services/migrations
diff options
context:
space:
mode:
authorSybren <122987084+drsybren@users.noreply.github.com>2023-01-24 20:44:55 +0100
committerGitHub <noreply@github.com>2023-01-24 19:44:55 +0000
commit25f4b7d7cd490384d8e714109036bbbbed2473ba (patch)
tree9ea3bc045b7d0f173cbc8bf7139b0dfa9894363b /services/migrations
parentb91bc680922a9f379ae026dea19c47e132d723af (diff)
downloadgitea-25f4b7d7cd490384d8e714109036bbbbed2473ba.tar.gz
gitea-25f4b7d7cd490384d8e714109036bbbbed2473ba.zip
Prevent duplicate labels when importing more than 99 (#22591)
Importing labels (via `gitea restore-repo`) did not split them up into batches properly. The first "batch" would create all labels, the second "batch" would create all labels except those in the first "batch", etc. This meant that when importing more than 99 labels (the batch size) there would always be duplicate ones. This is solved by actually passing `labels[:lbBatchSize]` to the `CreateLabels()` function, instead of the entire list `labels`.
Diffstat (limited to 'services/migrations')
-rw-r--r--services/migrations/migrate.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/migrations/migrate.go b/services/migrations/migrate.go
index a3b9d1cfa8..0ebb3411fd 100644
--- a/services/migrations/migrate.go
+++ b/services/migrations/migrate.go
@@ -281,7 +281,7 @@ func migrateRepository(doer *user_model.User, downloader base.Downloader, upload
lbBatchSize = len(labels)
}
- if err := uploader.CreateLabels(labels...); err != nil {
+ if err := uploader.CreateLabels(labels[:lbBatchSize]...); err != nil {
return err
}
labels = labels[lbBatchSize:]