mirror of
https://github.com/restic/restic.git
synced 2026-06-25 18:14:17 +00:00
Use array instead of hash for backend.ID
Since backend.ID is always a slice of constant length, use an array
instead of a slice. Mostly, arrays behave as slices, except that an
array cannot be nil, so use `*backend.ID` insteaf of `backend.ID` in
places where the absence of an ID is possible (e.g. for the Subtree of a
Node, which may not present when the node is a file node).
This change allows to directly use backend.ID as the the key for a map,
so that arbitrary data structures (e.g. a Set implemented as a
map[backend.ID]struct{}) can easily be formed.
This commit is contained in:
+5
-5
@@ -203,25 +203,25 @@ func TestLockRefresh(t *testing.T) {
|
||||
lock, err := restic.NewLock(repo)
|
||||
OK(t, err)
|
||||
|
||||
var lockID backend.ID
|
||||
var lockID *backend.ID
|
||||
for id := range repo.List(backend.Lock, nil) {
|
||||
if lockID != nil {
|
||||
t.Error("more than one lock found")
|
||||
}
|
||||
lockID = id
|
||||
lockID = &id
|
||||
}
|
||||
|
||||
OK(t, lock.Refresh())
|
||||
|
||||
var lockID2 backend.ID
|
||||
var lockID2 *backend.ID
|
||||
for id := range repo.List(backend.Lock, nil) {
|
||||
if lockID2 != nil {
|
||||
t.Error("more than one lock found")
|
||||
}
|
||||
lockID2 = id
|
||||
lockID2 = &id
|
||||
}
|
||||
|
||||
Assert(t, !lockID.Equal(lockID2),
|
||||
Assert(t, !lockID.Equal(*lockID2),
|
||||
"expected a new ID after lock refresh, got the same")
|
||||
OK(t, lock.Unlock())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user