forked from TrueCloudLab/restic
index: also mark old index as final on decode
This commit is contained in:
parent
2e6eee991d
commit
6c54d3fa82
3 changed files with 8 additions and 5 deletions
|
@ -64,11 +64,11 @@ func (r *Repacker) Repack() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("Repacker.Repack", "rebuild index")
|
debug.Log("Repacker.Repack", "rebuild index, unneeded packs: %v", unneededPacks)
|
||||||
idx, err := r.repo.Index().RebuildIndex(unneededPacks)
|
idx, err := r.repo.Index().RebuildIndex(unneededPacks)
|
||||||
|
|
||||||
newIndexID, err := repository.SaveIndex(r.repo, idx)
|
newIndexID, err := repository.SaveIndex(r.repo, idx)
|
||||||
debug.Log("Repacker.Repack", "saved new index at %v, err %v", newIndexID, err)
|
debug.Log("Repacker.Repack", "saved new index at %v, err %v", newIndexID.Str(), err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,6 +533,7 @@ func DecodeOldIndex(rd io.Reader) (idx *Index, err error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
idx.final = true
|
||||||
|
|
||||||
debug.Log("Index.DecodeOldIndex", "done")
|
debug.Log("Index.DecodeOldIndex", "done")
|
||||||
return idx, err
|
return idx, err
|
||||||
|
|
|
@ -248,14 +248,14 @@ func (mi *MasterIndex) RebuildIndex(packBlacklist backend.IDSet) (*Index, error)
|
||||||
mi.idxMutex.Lock()
|
mi.idxMutex.Lock()
|
||||||
defer mi.idxMutex.Unlock()
|
defer mi.idxMutex.Unlock()
|
||||||
|
|
||||||
debug.Log("MasterIndex.RebuildIndex", "start rebuilding index, blob blacklist: %v", packBlacklist)
|
debug.Log("MasterIndex.RebuildIndex", "start rebuilding index of %d indexes, pack blacklist: %v", len(mi.idx), packBlacklist)
|
||||||
|
|
||||||
newIndex := NewIndex()
|
newIndex := NewIndex()
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
for i, idx := range mi.idx {
|
for i, idx := range mi.idx {
|
||||||
debug.Log("MasterIndex.RebuildIndex", "adding %d index ", i)
|
debug.Log("MasterIndex.RebuildIndex", "adding index %d", i)
|
||||||
|
|
||||||
for pb := range idx.Each(done) {
|
for pb := range idx.Each(done) {
|
||||||
if packBlacklist.Has(pb.PackID) {
|
if packBlacklist.Has(pb.PackID) {
|
||||||
|
@ -266,15 +266,17 @@ func (mi *MasterIndex) RebuildIndex(packBlacklist backend.IDSet) (*Index, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !idx.Final() {
|
if !idx.Final() {
|
||||||
|
debug.Log("MasterIndex.RebuildIndex", "index %d isn't final, don't add to supersedes field", i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := idx.ID()
|
id, err := idx.ID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
debug.Log("MasterIndex.RebuildIndex", "index %d does not have an ID: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("MasterIndex.RebuildIndex", "adding index id %v to supersedes field", id)
|
debug.Log("MasterIndex.RebuildIndex", "adding index id %v to supersedes field", id.Str())
|
||||||
|
|
||||||
err = newIndex.AddToSupersedes(id)
|
err = newIndex.AddToSupersedes(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue