mirror of
https://github.com/restic/restic.git
synced 2026-11-22 13:24:24 +00:00
find: check blobIDs/treeIDs presence by length
Depending on the code path, the map could be initialized but stay empty.
This commit is contained in:
1 parent
db03aed816
commit
634e9b2411
1 file changed
+5
-5
@@ -378,7 +378,7 @@ func (f *Finder) findTree(treeID restic.ID, nodepath string) error {
|
|||||||
f.itemsFound++
|
f.itemsFound++
|
||||||
// Terminate if we have found all trees (and we are not
|
// Terminate if we have found all trees (and we are not
|
||||||
// looking for blobs)
|
// looking for blobs)
|
||||||
if f.itemsFound >= len(f.treeIDs) && f.blobIDs == nil {
|
if f.itemsFound >= len(f.treeIDs) && len(f.blobIDs) == 0 {
|
||||||
// Return an error to terminate the Walk
|
// Return an error to terminate the Walk
|
||||||
return errFindDone
|
return errFindDone
|
||||||
}
|
}
|
||||||
@@ -413,13 +413,13 @@ func (f *Finder) findIDs(ctx context.Context, sn *data.Snapshot) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type == "dir" && f.treeIDs != nil {
|
if node.Type == "dir" && len(f.treeIDs) > 0 {
|
||||||
if err := f.findTree(*node.Subtree, nodepath); err != nil {
|
if err := f.findTree(*node.Subtree, nodepath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type == data.NodeTypeFile && f.blobIDs != nil {
|
if node.Type == data.NodeTypeFile && len(f.blobIDs) > 0 {
|
||||||
for _, id := range node.Content {
|
for _, id := range node.Content {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
@@ -693,7 +693,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts global.Options, args [
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, sn := range filteredSnapshots {
|
for _, sn := range filteredSnapshots {
|
||||||
if f.blobIDs != nil || f.treeIDs != nil {
|
if len(f.blobIDs) > 0 || len(f.treeIDs) > 0 {
|
||||||
if err = f.findIDs(ctx, sn); err != nil && !errors.Is(err, errFindDone) {
|
if err = f.findIDs(ctx, sn); err != nil && !errors.Is(err, errFindDone) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -705,7 +705,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts global.Options, args [
|
|||||||
}
|
}
|
||||||
f.out.Finish()
|
f.out.Finish()
|
||||||
|
|
||||||
if opts.ShowPackID && (f.blobIDs != nil || f.treeIDs != nil) {
|
if opts.ShowPackID && (len(f.blobIDs) > 0 || len(f.treeIDs) > 0) {
|
||||||
f.findObjectsPacks()
|
f.findObjectsPacks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user