refactor(migration): use slices.Contains instead of local helper
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c2ef7a6c3b
commit
c4a02daeff
1 file changed
+6
-13
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user