check: Allow filling the cache during check

Closes #1665
This commit is contained in:
Alexander Neumann
2018-03-31 10:02:09 +02:00
parent 2e7ec717c1
commit e68a7fea8a
4 changed files with 24 additions and 6 deletions

View File

@@ -331,8 +331,20 @@ func (r *Repository) Index() restic.Index {
}
// SetIndex instructs the repository to use the given index.
func (r *Repository) SetIndex(i restic.Index) {
func (r *Repository) SetIndex(i restic.Index) error {
r.idx = i.(*MasterIndex)
ids := restic.NewIDSet()
for _, idx := range r.idx.All() {
id, err := idx.ID()
if err != nil {
debug.Log("not using index, ID() returned error %v", err)
continue
}
ids.Insert(id)
}
return r.PrepareCache(ids)
}
// SaveIndex saves an index in the repository.
@@ -428,6 +440,8 @@ func (r *Repository) PrepareCache(indexIDs restic.IDSet) error {
return nil
}
debug.Log("prepare cache with %d index files", len(indexIDs))
// clear old index files
err := r.Cache.Clear(restic.IndexFile, indexIDs)
if err != nil {