mirror of
https://github.com/octoleo/restic.git
synced 2024-11-29 08:14:03 +00:00
Merge pull request #717 from restic/fix-367
Only add entries to indexes inside PackerManager
This commit is contained in:
commit
04846b10bc
@ -119,16 +119,14 @@ func (mi *MasterIndex) Remove(index *Index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current returns an index that is not yet finalized, so that new entries can
|
// Store remembers the id and pack in the index.
|
||||||
// still be added. If all indexes are finalized, a new index is created and
|
func (mi *MasterIndex) Store(pb restic.PackedBlob) {
|
||||||
// returned.
|
|
||||||
func (mi *MasterIndex) Current() *Index {
|
|
||||||
mi.idxMutex.RLock()
|
mi.idxMutex.RLock()
|
||||||
|
|
||||||
for _, idx := range mi.idx {
|
for _, idx := range mi.idx {
|
||||||
if !idx.Final() {
|
if !idx.Final() {
|
||||||
mi.idxMutex.RUnlock()
|
mi.idxMutex.RUnlock()
|
||||||
return idx
|
idx.Store(pb)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +135,8 @@ func (mi *MasterIndex) Current() *Index {
|
|||||||
defer mi.idxMutex.Unlock()
|
defer mi.idxMutex.Unlock()
|
||||||
|
|
||||||
newIdx := NewIndex()
|
newIdx := NewIndex()
|
||||||
|
newIdx.Store(pb)
|
||||||
mi.idx = append(mi.idx, newIdx)
|
mi.idx = append(mi.idx, newIdx)
|
||||||
|
|
||||||
return newIdx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotFinalIndexes returns all indexes that have not yet been saved.
|
// NotFinalIndexes returns all indexes that have not yet been saved.
|
||||||
|
@ -133,7 +133,7 @@ func (r *Repository) savePacker(p *pack.Packer) error {
|
|||||||
// update blobs in the index
|
// update blobs in the index
|
||||||
for _, b := range p.Blobs() {
|
for _, b := range p.Blobs() {
|
||||||
debug.Log(" updating blob %v to pack %v", b.ID.Str(), id.Str())
|
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{
|
Blob: restic.Blob{
|
||||||
Type: b.Type,
|
Type: b.Type,
|
||||||
ID: b.ID,
|
ID: b.ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user