index: also mark old index as final on decode

This commit is contained in:
Alexander Neumann 2015-11-08 22:21:29 +01:00
parent 2e6eee991d
commit 6c54d3fa82
3 changed files with 8 additions and 5 deletions

View File

@ -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)
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 {
return err
}

View File

@ -533,6 +533,7 @@ func DecodeOldIndex(rd io.Reader) (idx *Index, err error) {
})
}
}
idx.final = true
debug.Log("Index.DecodeOldIndex", "done")
return idx, err

View File

@ -248,14 +248,14 @@ func (mi *MasterIndex) RebuildIndex(packBlacklist backend.IDSet) (*Index, error)
mi.idxMutex.Lock()
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()
done := make(chan struct{})
defer close(done)
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) {
if packBlacklist.Has(pb.PackID) {
@ -266,15 +266,17 @@ func (mi *MasterIndex) RebuildIndex(packBlacklist backend.IDSet) (*Index, error)
}
if !idx.Final() {
debug.Log("MasterIndex.RebuildIndex", "index %d isn't final, don't add to supersedes field", i)
continue
}
id, err := idx.ID()
if err != nil {
debug.Log("MasterIndex.RebuildIndex", "index %d does not have an ID: %v", 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)
if err != nil {