mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
walk: Honor close of the done channel
This commit is contained in:
parent
1c14be8993
commit
8dba52dd71
1 changed files with 16 additions and 3 deletions
19
walk.go
19
walk.go
|
@ -21,7 +21,11 @@ func walkTree(repo *repository.Repository, path string, treeID backend.ID, done
|
||||||
|
|
||||||
t, err := LoadTree(repo, treeID)
|
t, err := LoadTree(repo, treeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jobCh <- WalkTreeJob{Path: path, Error: err}
|
select {
|
||||||
|
case jobCh <- WalkTreeJob{Path: path, Error: err}:
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +34,20 @@ func walkTree(repo *repository.Repository, path string, treeID backend.ID, done
|
||||||
if node.Type == "dir" {
|
if node.Type == "dir" {
|
||||||
walkTree(repo, p, node.Subtree, done, jobCh)
|
walkTree(repo, p, node.Subtree, done, jobCh)
|
||||||
} else {
|
} else {
|
||||||
jobCh <- WalkTreeJob{Path: p, Node: node}
|
select {
|
||||||
|
case jobCh <- WalkTreeJob{Path: p, Node: node}:
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jobCh <- WalkTreeJob{Path: path, Tree: t}
|
select {
|
||||||
|
case jobCh <- WalkTreeJob{Path: path, Tree: t}:
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
debug.Log("walkTree", "done for %q (%v)", path, treeID.Str())
|
debug.Log("walkTree", "done for %q (%v)", path, treeID.Str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue