mirror of
https://github.com/restic/restic.git
synced 2026-10-11 12:37:13 +00:00
restic: ignore filenames which are not IDs when expanding a prefix
Some backends generate additional files for each existing file, e.g. 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef.sha256 For some commands this leads to an "multiple IDs with prefix" error when trying to reference a snapshot.
This commit is contained in:
1 parent
d6575f53ca
commit
5d3c5b9e50
2 files changed
+18
No files matched your search
@@ -3,6 +3,8 @@ package restic
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/restic/restic/internal/debug"
|
||||
)
|
||||
|
||||
// A MultipleIDMatchesError is returned by Find() when multiple IDs with a
|
||||
@@ -31,6 +33,13 @@ func Find(ctx context.Context, be Lister, t FileType, prefix string) (string, er
|
||||
defer cancel()
|
||||
|
||||
err := be.List(ctx, t, func(fi FileInfo) error {
|
||||
// ignore filename which are not an id
|
||||
_, err := ParseID(fi.Name)
|
||||
if err != nil {
|
||||
debug.Log("unable to parse %v as an ID", fi.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(fi.Name) >= len(prefix) && prefix == fi.Name[:len(prefix)] {
|
||||
if match == "" {
|
||||
match = fi.Name
|
||||
|
||||
Reference in new issue
Block a user