Skip to content

Commit

Permalink
Prevent duplicate labels when importing more than 99 (#22591)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
drsybren authored and yardenshoham committed Jan 24, 2023
1 parent f6cb786 commit 538a6f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion services/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down

0 comments on commit 538a6f2

Please sign in to comment.