diff options
author | Alexander Neumann <alexander@bumpern.de> | 2015-10-25 22:34:22 +0100 |
---|---|---|
committer | Alexander Neumann <alexander@bumpern.de> | 2015-10-25 22:34:22 +0100 |
commit | 74cd134b54c946ba2fb23ab713dc9cb6be52849a (patch) | |
tree | 6b4e2c94c4c1083130af7c9b98367ada88f2ecda /cmd | |
parent | 734ae7fcb8064d5e2fe9488f2ad575262f8c89ec (diff) |
rebuild index: remember already stored blobs
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/restic/cmd_rebuild_index.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cmd/restic/cmd_rebuild_index.go b/cmd/restic/cmd_rebuild_index.go index 5444cacb2..bcce5d61f 100644 --- a/cmd/restic/cmd_rebuild_index.go +++ b/cmd/restic/cmd_rebuild_index.go @@ -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) |