mirror of
https://github.com/octoleo/restic.git
synced 2025-01-05 08:02:22 +00:00
Merge pull request #2321 from restic/fix-index-error-handling
Check errors returned by LoadIndex()
This commit is contained in:
commit
01c51b3449
8
changelog/unreleased/plul-2321
Normal file
8
changelog/unreleased/plul-2321
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Bugfix: Check errors when loading index files
|
||||||
|
|
||||||
|
Restic now checks and handles errors which occur when loading index files, the
|
||||||
|
missing check leads to odd errors (and a stack trace printed to users) later.
|
||||||
|
This was reported in the forum.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/2321
|
||||||
|
https://forum.restic.net/t/check-rebuild-index-prune/1848/13
|
@ -440,6 +440,10 @@ func (r *Repository) LoadIndex(ctx context.Context) error {
|
|||||||
idx, buf, err = LoadIndexWithDecoder(ctx, r, buf[:0], fi.ID, DecodeOldIndex)
|
idx, buf, err = LoadIndexWithDecoder(ctx, r, buf[:0], fi.ID, DecodeOldIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, fmt.Sprintf("unable to load index %v", fi.ID.Str()))
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case indexCh <- idx:
|
case indexCh <- idx:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@ -475,7 +479,7 @@ func (r *Repository) LoadIndex(ctx context.Context) error {
|
|||||||
|
|
||||||
err := wg.Wait()
|
err := wg.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove index files from the cache which have been removed in the repo
|
// remove index files from the cache which have been removed in the repo
|
||||||
|
Loading…
Reference in New Issue
Block a user