From 5a87a0ba0ab4f87703a4f290983575a5c0d97182 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 15 May 2021 23:08:15 +0200 Subject: [PATCH] find: use Str() to format short ids --- cmd/restic/cmd_find.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index 378d6cbdc..45d42b45f 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -40,8 +40,6 @@ Exit status is 0 if the command was successful, and non-zero if there was any er }, } -const shortStr = 8 // Length of short IDs: 4 bytes as hex strings - // FindOptions bundles all options for the find command. type FindOptions struct { Oldest string @@ -386,12 +384,12 @@ func (f *Finder) findIDs(ctx context.Context, sn *restic.Snapshot) error { idStr := id.String() if _, ok := f.blobIDs[idStr]; !ok { // Look for short ID form - if _, ok := f.blobIDs[idStr[:shortStr]]; !ok { + if _, ok := f.blobIDs[id.Str()]; !ok { continue } // Replace the short ID with the long one f.blobIDs[idStr] = struct{}{} - delete(f.blobIDs, idStr[:shortStr]) + delete(f.blobIDs, id.Str()) } f.out.PrintObject("blob", idStr, nodepath, parentTreeID.String(), sn) } @@ -423,7 +421,7 @@ func (f *Finder) packsToBlobs(ctx context.Context, packs []string) error { idStr := id.String() if _, ok := packIDs[idStr]; !ok { // Look for short ID form - if _, ok := packIDs[idStr[:shortStr]]; !ok { + if _, ok := packIDs[id.Str()]; !ok { return nil } }