From 538a6f235be432e59c83899f2a8dcb2e53c3e60c Mon Sep 17 00:00:00 2001 From: Sybren <122987084+drsybren@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:44:55 +0100 Subject: [PATCH] Prevent duplicate labels when importing more than 99 (#22591) 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`. --- services/migrations/migrate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/migrations/migrate.go b/services/migrations/migrate.go index dfb21b884bbb8..271fdf7f3de77 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:]