mirror of
https://github.com/restic/restic.git
synced 2026-05-28 04:35:41 -04:00
find: use proper sentinel error to terminate search
This commit is contained in:
parent
91c2aefbe1
commit
febdb8b564
1 changed files with 5 additions and 2 deletions
|
|
@ -22,6 +22,9 @@ import (
|
|||
"github.com/restic/restic/internal/walker"
|
||||
)
|
||||
|
||||
// errFindDone is returned from the tree walk when all requested tree IDs were found.
|
||||
var errFindDone = errors.New("find: all tree IDs found")
|
||||
|
||||
func newFindCommand(globalOptions *global.Options) *cobra.Command {
|
||||
var opts FindOptions
|
||||
|
||||
|
|
@ -375,7 +378,7 @@ func (f *Finder) findTree(treeID restic.ID, nodepath string) error {
|
|||
// looking for blobs)
|
||||
if f.itemsFound >= len(f.treeIDs) && f.blobIDs == nil {
|
||||
// Return an error to terminate the Walk
|
||||
return errors.New("OK")
|
||||
return errFindDone
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -688,7 +691,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts global.Options, args [
|
|||
|
||||
for _, sn := range filteredSnapshots {
|
||||
if f.blobIDs != nil || f.treeIDs != nil {
|
||||
if err = f.findIDs(ctx, sn); err != nil && err.Error() != "OK" {
|
||||
if err = f.findIDs(ctx, sn); err != nil && !errors.Is(err, errFindDone) {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue