2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-02 09:00:50 +00:00

Merge pull request #717 from restic/fix-367

Only add entries to indexes inside PackerManager
This commit is contained in:
Alexander Neumann 2017-01-02 17:18:59 +01:00
commit 04846b10bc
2 changed files with 6 additions and 9 deletions

View File

@ -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.

View File

@ -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,