restic: Don't list snapshots if FindSnapshot gets full id
This commit is contained in:
parent
d8c00b9726
commit
246d3032ae
1 changed files with 11 additions and 7 deletions
|
@ -73,15 +73,19 @@ func findLatestSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, h
|
||||||
// FindSnapshot takes a string and tries to find a snapshot whose ID matches
|
// FindSnapshot takes a string and tries to find a snapshot whose ID matches
|
||||||
// the string as closely as possible.
|
// the string as closely as possible.
|
||||||
func FindSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, s string) (*Snapshot, error) {
|
func FindSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, s string) (*Snapshot, error) {
|
||||||
// find snapshot id with prefix
|
// no need to list snapshots if `s` is already a full id
|
||||||
name, err := Find(ctx, be, SnapshotFile, s)
|
id, err := ParseID(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
// find snapshot id with prefix
|
||||||
}
|
name, err := Find(ctx, be, SnapshotFile, s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
id, err := ParseID(name)
|
id, err = ParseID(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return LoadSnapshot(ctx, loader, id)
|
return LoadSnapshot(ctx, loader, id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue