summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYarden Shoham <hrsi88@gmail.com>2023-01-24 22:48:21 +0200
committerGitHub <noreply@github.com>2023-01-24 14:48:21 -0600
commitf204ff4ef71ef0eb6b58e4e3e026d0fe0c3ce9d6 (patch)
treede06aae89166db072c102a571d54aadd51285169
parentf6cb7860a2ec78a69cf0f92a1f2b1e9f4f9bc8be (diff)
downloadgitea-f204ff4ef71ef0eb6b58e4e3e026d0fe0c3ce9d6.tar.gz
gitea-f204ff4ef71ef0eb6b58e4e3e026d0fe0c3ce9d6.zip
Prevent duplicate labels when importing more than 99 (#22591) (#22598)
Backport #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`. Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
-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 dfb21b884b..271fdf7f3d 100644
--- a/services/migrations/migrate.go
+++ b/services/migrations/migrate.go
@@ -282,7 +282,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:]