7
7
"fmt"
8
8
"io"
9
9
slog "log"
10
+ "maps"
10
11
"math/rand"
11
12
"net"
12
13
"os"
@@ -508,7 +509,7 @@ func (r *PhysRestore) toState(status defs.Status) (_ defs.Status, err error) {
508
509
509
510
if r .nodeInfo .IsPrimary || status == defs .StatusDone {
510
511
r .log .Info ("waiting for `%s` status in rs %v" , status , r .syncPathPeers )
511
- cstat , err := r .waitFiles (status , copyMap (r .syncPathPeers ), false )
512
+ cstat , err := r .waitFiles (status , maps . Clone (r .syncPathPeers ), false )
512
513
if err != nil {
513
514
return defs .StatusError , errors .Wrap (err , "wait for nodes in rs" )
514
515
}
@@ -521,7 +522,7 @@ func (r *PhysRestore) toState(status defs.Status) (_ defs.Status, err error) {
521
522
522
523
if r .nodeInfo .IsClusterLeader () || status == defs .StatusDone {
523
524
r .log .Info ("waiting for shards %v" , r .syncPathShards )
524
- cstat , err := r .waitFiles (status , copyMap (r .syncPathShards ), true )
525
+ cstat , err := r .waitFiles (status , maps . Clone (r .syncPathShards ), true )
525
526
if err != nil {
526
527
return defs .StatusError , errors .Wrap (err , "wait for shards" )
527
528
}
@@ -592,15 +593,6 @@ func (n nodeError) Error() string {
592
593
return fmt .Sprintf ("%s failed: %s" , n .node , n .msg )
593
594
}
594
595
595
- func copyMap [K comparable , V any ](m map [K ]V ) map [K ]V {
596
- cp := make (map [K ]V )
597
- for k , v := range m {
598
- cp [k ] = v
599
- }
600
-
601
- return cp
602
- }
603
-
604
596
func (r * PhysRestore ) waitFiles (
605
597
status defs.Status ,
606
598
objs map [string ]struct {},
@@ -1717,7 +1709,7 @@ func (r *PhysRestore) agreeCommonRestoreTS() (primitive.Timestamp, error) {
1717
1709
}
1718
1710
1719
1711
if r .nodeInfo .IsClusterLeader () {
1720
- _ , err := r .waitFiles (defs .StatusExtTS , copyMap (r .syncPathShards ), true )
1712
+ _ , err := r .waitFiles (defs .StatusExtTS , maps . Clone (r .syncPathShards ), true )
1721
1713
if err != nil {
1722
1714
return ts , errors .Wrap (err , "wait for shards timestamp" )
1723
1715
}
@@ -1766,7 +1758,7 @@ func (r *PhysRestore) setcommittedTxn(_ context.Context, txn []phys.RestoreTxn)
1766
1758
}
1767
1759
1768
1760
func (r * PhysRestore ) getcommittedTxn (context.Context ) (map [string ]primitive.Timestamp , error ) {
1769
- shards := copyMap (r .syncPathShards )
1761
+ shards := maps . Clone (r .syncPathShards )
1770
1762
txn := make (map [string ]primitive.Timestamp )
1771
1763
for len (shards ) > 0 {
1772
1764
for f := range shards {
0 commit comments