checker: Pass on error loading an index
This commit is contained in:
parent
b40aa66985
commit
7797e084f9
1 changed files with 15 additions and 15 deletions
|
@ -80,6 +80,7 @@ func (c *Checker) LoadIndex() (hints []error, errs []error) {
|
||||||
debug.Log("Start")
|
debug.Log("Start")
|
||||||
type indexRes struct {
|
type indexRes struct {
|
||||||
Index *repository.Index
|
Index *repository.Index
|
||||||
|
err error
|
||||||
ID string
|
ID string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,39 +96,40 @@ func (c *Checker) LoadIndex() (hints []error, errs []error) {
|
||||||
idx, err = repository.LoadIndexWithDecoder(c.repo, id, repository.DecodeOldIndex)
|
idx, err = repository.LoadIndexWithDecoder(c.repo, id, repository.DecodeOldIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
err = errors.Wrapf(err, "error loading index %v", id.Str())
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case indexCh <- indexRes{Index: idx, ID: id.String()}:
|
case indexCh <- indexRes{Index: idx, ID: id.String(), err: err}:
|
||||||
case <-done:
|
case <-done:
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var perr error
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(indexCh)
|
defer close(indexCh)
|
||||||
debug.Log("start loading indexes in parallel")
|
debug.Log("start loading indexes in parallel")
|
||||||
perr = repository.FilesInParallel(c.repo.Backend(), restic.IndexFile, defaultParallelism,
|
err := repository.FilesInParallel(c.repo.Backend(), restic.IndexFile, defaultParallelism,
|
||||||
repository.ParallelWorkFuncParseID(worker))
|
repository.ParallelWorkFuncParseID(worker))
|
||||||
debug.Log("loading indexes finished, error: %v", perr)
|
debug.Log("loading indexes finished, error: %v", err)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
if perr != nil {
|
|
||||||
errs = append(errs, perr)
|
|
||||||
return hints, errs
|
|
||||||
}
|
|
||||||
|
|
||||||
packToIndex := make(map[restic.ID]restic.IDSet)
|
packToIndex := make(map[restic.ID]restic.IDSet)
|
||||||
|
|
||||||
for res := range indexCh {
|
for res := range indexCh {
|
||||||
debug.Log("process index %v", res.ID)
|
debug.Log("process index %v, err %v", res.ID, res.err)
|
||||||
|
|
||||||
|
if res.err != nil {
|
||||||
|
errs = append(errs, res.err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
idxID, err := restic.ParseID(res.ID)
|
idxID, err := restic.ParseID(res.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, errors.Errorf("unable to parse as index ID: %v", res.ID))
|
errs = append(errs, errors.Errorf("unable to parse as index ID: %v", res.ID))
|
||||||
|
@ -154,8 +156,6 @@ func (c *Checker) LoadIndex() (hints []error, errs []error) {
|
||||||
debug.Log("%d blobs processed", cnt)
|
debug.Log("%d blobs processed", cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("done, error %v", perr)
|
|
||||||
|
|
||||||
debug.Log("checking for duplicate packs")
|
debug.Log("checking for duplicate packs")
|
||||||
for packID := range c.packs {
|
for packID := range c.packs {
|
||||||
debug.Log(" check pack %v: contained in %d indexes", packID.Str(), len(packToIndex[packID]))
|
debug.Log(" check pack %v: contained in %d indexes", packID.Str(), len(packToIndex[packID]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue