diff --git a/src/restic/repository/master_index.go b/src/restic/repository/master_index.go index b037ac23f..165bf6024 100644 --- a/src/restic/repository/master_index.go +++ b/src/restic/repository/master_index.go @@ -119,16 +119,14 @@ func (mi *MasterIndex) Remove(index *Index) { } } -// Current returns an index that is not yet finalized, so that new entries can -// still be added. If all indexes are finalized, a new index is created and -// returned. -func (mi *MasterIndex) Current() *Index { +// Store remembers the id and pack in the index. +func (mi *MasterIndex) Store(pb restic.PackedBlob) { mi.idxMutex.RLock() - for _, idx := range mi.idx { if !idx.Final() { mi.idxMutex.RUnlock() - return idx + idx.Store(pb) + return } } @@ -137,9 +135,8 @@ func (mi *MasterIndex) Current() *Index { defer mi.idxMutex.Unlock() newIdx := NewIndex() + newIdx.Store(pb) mi.idx = append(mi.idx, newIdx) - - return newIdx } // NotFinalIndexes returns all indexes that have not yet been saved. diff --git a/src/restic/repository/packer_manager.go b/src/restic/repository/packer_manager.go index 499abd90b..c686effe6 100644 --- a/src/restic/repository/packer_manager.go +++ b/src/restic/repository/packer_manager.go @@ -133,7 +133,7 @@ func (r *Repository) savePacker(p *pack.Packer) error { // update blobs in the index for _, b := range p.Blobs() { debug.Log(" updating blob %v to pack %v", b.ID.Str(), id.Str()) - r.idx.Current().Store(restic.PackedBlob{ + r.idx.Store(restic.PackedBlob{ Blob: restic.Blob{ Type: b.Type, ID: b.ID,