forked from TrueCloudLab/restic
parent
2e7ec717c1
commit
e68a7fea8a
4 changed files with 24 additions and 6 deletions
|
@ -164,7 +164,11 @@ func (c *Checker) LoadIndex(ctx context.Context) (hints []error, errs []error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.repo.SetIndex(c.masterIndex)
|
err := c.repo.SetIndex(c.masterIndex)
|
||||||
|
if err != nil {
|
||||||
|
debug.Log("SetIndex returned error: %v", err)
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
|
||||||
return hints, errs
|
return hints, errs
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ type Repository struct {
|
||||||
|
|
||||||
KeyFn func() *crypto.Key
|
KeyFn func() *crypto.Key
|
||||||
|
|
||||||
SetIndexFn func(restic.Index)
|
SetIndexFn func(restic.Index) error
|
||||||
|
|
||||||
IndexFn func() restic.Index
|
IndexFn func() restic.Index
|
||||||
SaveFullIndexFn func() error
|
SaveFullIndexFn func() error
|
||||||
|
@ -51,8 +51,8 @@ func (repo Repository) Key() *crypto.Key {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIndex is a stub method.
|
// SetIndex is a stub method.
|
||||||
func (repo Repository) SetIndex(idx restic.Index) {
|
func (repo Repository) SetIndex(idx restic.Index) error {
|
||||||
repo.SetIndexFn(idx)
|
return repo.SetIndexFn(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index is a stub method.
|
// Index is a stub method.
|
||||||
|
|
|
@ -331,8 +331,20 @@ func (r *Repository) Index() restic.Index {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIndex instructs the repository to use the given 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)
|
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.
|
// SaveIndex saves an index in the repository.
|
||||||
|
@ -428,6 +440,8 @@ func (r *Repository) PrepareCache(indexIDs restic.IDSet) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug.Log("prepare cache with %d index files", len(indexIDs))
|
||||||
|
|
||||||
// clear old index files
|
// clear old index files
|
||||||
err := r.Cache.Clear(restic.IndexFile, indexIDs)
|
err := r.Cache.Clear(restic.IndexFile, indexIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -15,7 +15,7 @@ type Repository interface {
|
||||||
|
|
||||||
Key() *crypto.Key
|
Key() *crypto.Key
|
||||||
|
|
||||||
SetIndex(Index)
|
SetIndex(Index) error
|
||||||
|
|
||||||
Index() Index
|
Index() Index
|
||||||
SaveFullIndex(context.Context) error
|
SaveFullIndex(context.Context) error
|
||||||
|
|
Loading…
Reference in a new issue