mirror of
https://github.com/restic/restic.git
synced 2025-08-22 03:08:09 +00:00
@@ -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 {
|
||||
|
Reference in New Issue
Block a user