mirror of
https://github.com/restic/restic.git
synced 2025-10-21 05:50:10 +00:00
Add checks for Server.Load(), use Blob for load
This commit is contained in:
19
walk.go
19
walk.go
@@ -3,7 +3,6 @@ package restic
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/restic/restic/backend"
|
||||
"github.com/restic/restic/debug"
|
||||
)
|
||||
|
||||
@@ -15,10 +14,10 @@ type WalkTreeJob struct {
|
||||
Tree *Tree
|
||||
}
|
||||
|
||||
func walkTree(s Server, path string, id backend.ID, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("walkTree", "start on %q (%v)", path, id.Str())
|
||||
func walkTree(s Server, path string, treeBlob Blob, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("walkTree", "start on %q (%v)", path, treeBlob)
|
||||
// load tree
|
||||
t, err := LoadTree(s, id)
|
||||
t, err := LoadTree(s, treeBlob)
|
||||
if err != nil {
|
||||
jobCh <- WalkTreeJob{Path: path, Error: err}
|
||||
return
|
||||
@@ -32,27 +31,27 @@ func walkTree(s Server, path string, id backend.ID, done chan struct{}, jobCh ch
|
||||
jobCh <- WalkTreeJob{Path: p, Error: err}
|
||||
continue
|
||||
}
|
||||
walkTree(s, p, blob.Storage, done, jobCh)
|
||||
walkTree(s, p, blob, done, jobCh)
|
||||
} else {
|
||||
// load old blobs
|
||||
node.blobs, err = t.Map.Select(node.Content)
|
||||
if err != nil {
|
||||
debug.Log("walkTree", "unable to load bobs for %q (%v): %v", path, id.Str(), err)
|
||||
debug.Log("walkTree", "unable to load bobs for %q (%v): %v", path, treeBlob, err)
|
||||
}
|
||||
jobCh <- WalkTreeJob{Path: p, Node: node, Error: err}
|
||||
}
|
||||
}
|
||||
|
||||
jobCh <- WalkTreeJob{Path: filepath.Join(path), Tree: t}
|
||||
debug.Log("walkTree", "done for %q (%v)", path, id.Str())
|
||||
debug.Log("walkTree", "done for %q (%v)", path, treeBlob)
|
||||
}
|
||||
|
||||
// WalkTree walks the tree specified by ID recursively and sends a job for each
|
||||
// file and directory it finds. When the channel done is closed, processing
|
||||
// stops.
|
||||
func WalkTree(server Server, id backend.ID, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("WalkTree", "start on %v", id.Str())
|
||||
walkTree(server, "", id, done, jobCh)
|
||||
func WalkTree(server Server, blob Blob, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("WalkTree", "start on %v", blob)
|
||||
walkTree(server, "", blob, done, jobCh)
|
||||
close(jobCh)
|
||||
debug.Log("WalkTree", "done")
|
||||
}
|
||||
|
Reference in New Issue
Block a user