mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
Handle null subtree IDs
This commit is contained in:
parent
72fcd00859
commit
86c8328f62
@ -276,7 +276,7 @@ func loadSnapshotTreeIDs(repo *repository.Repository) (backend.IDs, []error) {
|
|||||||
return trees.IDs, errs.errs
|
return trees.IDs, errs.errs
|
||||||
}
|
}
|
||||||
|
|
||||||
// TreeError is returned when loading a tree from the repository failed.
|
// TreeError collects several errors that occurred while processing a tree.
|
||||||
type TreeError struct {
|
type TreeError struct {
|
||||||
ID backend.ID
|
ID backend.ID
|
||||||
Errors []error
|
Errors []error
|
||||||
@ -335,7 +335,7 @@ func loadTreeWorker(repo *repository.Repository,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkTreeWorker checks the trees received and sends out errors to errChan.
|
// checkTreeWorker checks the trees received and sends out errors to errChan.
|
||||||
func (c *Checker) checkTreeWorker(in <-chan treeJob, out chan<- TreeError, done <-chan struct{}, wg *sync.WaitGroup) {
|
func (c *Checker) checkTreeWorker(in <-chan treeJob, out chan<- error, done <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
defer func() {
|
defer func() {
|
||||||
debug.Log("checker.checkTreeWorker", "exiting")
|
debug.Log("checker.checkTreeWorker", "exiting")
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -351,10 +351,12 @@ func (c *Checker) checkTreeWorker(in <-chan treeJob, out chan<- TreeError, done
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
|
debug.Log("checker.checkTreeWorker", "done channel closed, exiting")
|
||||||
return
|
return
|
||||||
|
|
||||||
case job, ok := <-inCh:
|
case job, ok := <-inCh:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
debug.Log("checker.checkTreeWorker", "input channel closed, exiting")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,9 +374,15 @@ func (c *Checker) checkTreeWorker(in <-chan treeJob, out chan<- TreeError, done
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("checker.checkTreeWorker", "load tree %v", job.ID.Str())
|
debug.Log("checker.checkTreeWorker", "check tree %v (tree %v, err %v)", job.ID.Str(), job.Tree, job.error)
|
||||||
|
|
||||||
|
var errs []error
|
||||||
|
if job.error != nil {
|
||||||
|
errs = append(errs, job.error)
|
||||||
|
} else {
|
||||||
|
errs = c.checkTree(job.ID, job.Tree)
|
||||||
|
}
|
||||||
|
|
||||||
errs := c.checkTree(job.ID, job.Tree)
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
debug.Log("checker.checkTreeWorker", "checked tree %v: %v errors", job.ID.Str(), len(errs))
|
debug.Log("checker.checkTreeWorker", "checked tree %v: %v errors", job.ID.Str(), len(errs))
|
||||||
treeError = TreeError{ID: job.ID, Errors: errs}
|
treeError = TreeError{ID: job.ID, Errors: errs}
|
||||||
@ -438,7 +446,7 @@ func filterTrees(backlog backend.IDs, loaderChan chan<- backend.ID, in <-chan tr
|
|||||||
|
|
||||||
outstandingLoadTreeJobs--
|
outstandingLoadTreeJobs--
|
||||||
|
|
||||||
debug.Log("checker.filterTrees", "input job tree %v, subtrees %v", j.ID.Str(), j.Tree.Subtrees())
|
debug.Log("checker.filterTrees", "input job tree %v", j.ID.Str())
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -448,10 +456,13 @@ func filterTrees(backlog backend.IDs, loaderChan chan<- backend.ID, in <-chan tr
|
|||||||
debug.Log("checker.filterTrees", "received job with nil tree pointer: %v (ID %v)", j.error, j.ID.Str())
|
debug.Log("checker.filterTrees", "received job with nil tree pointer: %v (ID %v)", j.error, j.ID.Str())
|
||||||
err = errors.New("tree is nil and error is nil")
|
err = errors.New("tree is nil and error is nil")
|
||||||
} else {
|
} else {
|
||||||
|
debug.Log("checker.filterTrees", "subtrees for tree %v: %v", j.ID.Str(), j.Tree.Subtrees())
|
||||||
for _, id := range j.Tree.Subtrees() {
|
for _, id := range j.Tree.Subtrees() {
|
||||||
if id.IsNull() {
|
if id.IsNull() {
|
||||||
|
// We do not need to raise this error here, it is
|
||||||
|
// checked when the tree is checked. Just make sure
|
||||||
|
// that we do not add any null IDs to the backlog.
|
||||||
debug.Log("checker.filterTrees", "tree %v has nil subtree", j.ID.Str())
|
debug.Log("checker.filterTrees", "tree %v has nil subtree", j.ID.Str())
|
||||||
err = fmt.Errorf("tree %v has subtree with null ID", j.ID)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
backlog = append(backlog, id)
|
backlog = append(backlog, id)
|
||||||
|
Loading…
Reference in New Issue
Block a user