internal/restic: Use IDSet.Clone + use maps package

One place where IDSet.Clone is useful was reinventing it, using a
conversion to list, a sort, and a conversion back to map.

Also, use the stdlib "maps" package to implement as much of IDSet as
possible. This requires changing one caller, which assumed that cloning
nil would return a non-nil IDSet.
This commit is contained in:
greatroar
2024-09-30 22:43:04 +02:00
parent efec1a5e96
commit b5c28a7ba2
3 changed files with 11 additions and 27 deletions

View File

@@ -347,6 +347,9 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked, exclud
// copy excludePacks to prevent unintended sideeffects
excludePacks = excludePacks.Clone()
if excludePacks == nil {
excludePacks = restic.NewIDSet()
}
debug.Log("start rebuilding index of %d indexes, excludePacks: %v", len(indexes), excludePacks)
wg, wgCtx := errgroup.WithContext(ctx)