mirror of
https://github.com/restic/restic.git
synced 2026-11-10 00:51:09 +00:00
Major restructure, bundle blobs
This commit also breaks the repository format.
This commit is contained in:
1 parent
b836da1980
commit
60a0fe8349
29 files changed
+937
-1123
No files matched your search
@@ -3,6 +3,7 @@ package restic
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/restic/restic/backend"
|
||||
"github.com/restic/restic/debug"
|
||||
"github.com/restic/restic/server"
|
||||
)
|
||||
@@ -15,10 +16,10 @@ type WalkTreeJob struct {
|
||||
Tree *Tree
|
||||
}
|
||||
|
||||
func walkTree(s *server.Server, path string, treeBlob server.Blob, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("walkTree", "start on %q (%v)", path, treeBlob)
|
||||
func walkTree(s *server.Server, path string, treeID backend.ID, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("walkTree", "start on %q (%v)", path, treeID.Str())
|
||||
// load tree
|
||||
t, err := LoadTree(s, treeBlob)
|
||||
t, err := LoadTree(s, treeID)
|
||||
if err != nil {
|
||||
jobCh <- WalkTreeJob{Path: path, Error: err}
|
||||
return
|
||||
@@ -27,32 +28,22 @@ func walkTree(s *server.Server, path string, treeBlob server.Blob, done chan str
|
||||
for _, node := range t.Nodes {
|
||||
p := filepath.Join(path, node.Name)
|
||||
if node.Type == "dir" {
|
||||
blob, err := t.Map.FindID(node.Subtree)
|
||||
if err != nil {
|
||||
jobCh <- WalkTreeJob{Path: p, Error: err}
|
||||
continue
|
||||
}
|
||||
walkTree(s, p, blob, done, jobCh)
|
||||
walkTree(s, p, node.Subtree, 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, 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, treeBlob)
|
||||
debug.Log("walkTree", "done for %q (%v)", path, treeID.Str())
|
||||
}
|
||||
|
||||
// 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.Server, blob server.Blob, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("WalkTree", "start on %v", blob)
|
||||
walkTree(server, "", blob, done, jobCh)
|
||||
func WalkTree(server *server.Server, id backend.ID, done chan struct{}, jobCh chan<- WalkTreeJob) {
|
||||
debug.Log("WalkTree", "start on %v", id.Str())
|
||||
walkTree(server, "", id, done, jobCh)
|
||||
close(jobCh)
|
||||
debug.Log("WalkTree", "done")
|
||||
}
|
||||
Reference in new issue
Block a user