From c4a02daeff6f9af9c92d10d2e4db63b5dc88195b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Thu, 3 Dec 2026 18:08:01 +0100 Subject: [PATCH] refactor(migration): use slices.Contains instead of local helper Co-Authored-By: Claude Opus 5.5 --- internal/migration/engine.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/migration/engine.go b/internal/migration/engine.go index c6a1a01..e69f4c8 100644 --- a/internal/migration/engine.go +++ b/internal/migration/engine.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" "reflect" + "slices" "sort" "strings" "syscall" @@ -319,7 +320,7 @@ func (e Engine) Sync(ctx context.Context, c Config, statePath string, final bool } defer claim.Close() s.Config = c - if !contains(s.Notes, SnapshotIdentityNote) { + if !slices.Contains(s.Notes, SnapshotIdentityNote) { s.Notes = append(s.Notes, SnapshotIdentityNote) if err = SaveState(abs, s); err != nil { return err @@ -381,7 +382,7 @@ func (e Engine) Sync(ctx context.Context, c Config, statePath string, final bool for i := range s.Snapshots { if s.Snapshots[i].Done { snap := &s.Snapshots[i] - if !contains(targetNames, snap.Name) { + if !slices.Contains(targetNames, snap.Name) { return fmt.Errorf("completed target snapshot %q disappeared", snap.Name) } info, err := snapshotDetails(ctx, dst, snap.Name) @@ -391,7 +392,7 @@ func (e Engine) Sync(ctx context.Context, c Config, statePath string, final bool if info.CreatedAt != snap.TargetCreatedAt { return fmt.Errorf("completed target snapshot %q was replaced", snap.Name) } - if contains(inspection.SourceSnapshots, snap.Name) { + if slices.Contains(inspection.SourceSnapshots, snap.Name) { info, err = snapshotDetails(ctx, src, snap.Name) if err != nil { return err @@ -480,7 +481,7 @@ func (e Engine) transfer(ctx context.Context, src, dst ceph, target, statePath s if err != nil { return err } - if !contains(names, snap.Name) { + if !slices.Contains(names, snap.Name) { if !snap.Owned || snap.CreatedAt != "" { return fmt.Errorf("source snapshot %q disappeared before transfer", snap.Name) } @@ -508,7 +509,7 @@ func (e Engine) transfer(ctx context.Context, src, dst ceph, target, statePath s return err } aware, isNative := e.Transport.(RoundTransport) - existed := contains(targetNames, snap.Name) + existed := slices.Contains(targetNames, snap.Name) if isNative { round := Round{SourcePath: from, TargetPath: target, Name: snap.Name, StatePath: statePath, BaseName: s.LiveSnapshot} if s.LiveSnapshot != "" { @@ -591,11 +592,3 @@ func (e Engine) transfer(ctx context.Context, src, dst ceph, target, statePath s e.log("snapshot=%s: verified and committed", snap.Name) return nil } -func contains(names []string, name string) bool { - for _, n := range names { - if n == name { - return true - } - } - return false -}