From 88716794e3e02e38a73a6749cc5b340a65dcf7e8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 30 Jun 2019 21:34:53 +0200 Subject: [PATCH 1/2] Check errors returned by LoadIndex() Bug was reported in the forum here: https://forum.restic.net/t/check-rebuild-index-prune/1848/13 --- internal/repository/repository.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/repository/repository.go b/internal/repository/repository.go index cb78c25c1..0c71fb3bb 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -440,6 +440,10 @@ func (r *Repository) LoadIndex(ctx context.Context) error { 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 { case indexCh <- idx: case <-ctx.Done(): @@ -475,7 +479,7 @@ func (r *Repository) LoadIndex(ctx context.Context) error { err := wg.Wait() if err != nil { - return err + return errors.Fatal(err.Error()) } // remove index files from the cache which have been removed in the repo From 3f94f63967879cecb6b56ab49c44dfb80a94bb6c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 30 Jun 2019 21:38:10 +0200 Subject: [PATCH 2/2] Add entry to changelog --- changelog/unreleased/plul-2321 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/plul-2321 diff --git a/changelog/unreleased/plul-2321 b/changelog/unreleased/plul-2321 new file mode 100644 index 000000000..a8e69e048 --- /dev/null +++ b/changelog/unreleased/plul-2321 @@ -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