forked from TrueCloudLab/restic
rebuild index: remember already stored blobs
This commit is contained in:
parent
734ae7fcb8
commit
74cd134b54
1 changed files with 16 additions and 1 deletions
|
@ -61,6 +61,12 @@ func (cmd CmdRebuildIndex) RebuildIndex() error {
|
|||
combinedIndex := repository.NewIndex()
|
||||
packsDone := backend.NewIDSet()
|
||||
|
||||
type Blob struct {
|
||||
id backend.ID
|
||||
tpe pack.BlobType
|
||||
}
|
||||
blobsDone := make(map[Blob]struct{})
|
||||
|
||||
i := 0
|
||||
for indexID := range indexIDs {
|
||||
cmd.global.Printf(" loading index %v\n", i)
|
||||
|
@ -74,8 +80,17 @@ func (cmd CmdRebuildIndex) RebuildIndex() error {
|
|||
debug.Log("RebuildIndex.RebuildIndex", "adding blobs from index %v", indexID.Str())
|
||||
|
||||
for packedBlob := range idx.Each(done) {
|
||||
combinedIndex.Store(packedBlob.Type, packedBlob.ID, packedBlob.PackID, packedBlob.Offset, packedBlob.Length)
|
||||
packsDone.Insert(packedBlob.PackID)
|
||||
b := Blob{
|
||||
id: packedBlob.ID,
|
||||
tpe: packedBlob.Type,
|
||||
}
|
||||
if _, ok := blobsDone[b]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
blobsDone[b] = struct{}{}
|
||||
combinedIndex.Store(packedBlob.Type, packedBlob.ID, packedBlob.PackID, packedBlob.Offset, packedBlob.Length)
|
||||
}
|
||||
|
||||
combinedIndex.AddToSupersedes(indexID)
|
||||
|
|
Loading…
Reference in a new issue