mirror of
https://github.com/octoleo/restic.git
synced 2025-01-10 18:04:38 +00:00
Use PackSize in rebuild-index
This commit is contained in:
parent
ce5d630681
commit
4960b841e6
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/restic/restic/internal/pack"
|
|
||||||
"github.com/restic/restic/internal/repository"
|
"github.com/restic/restic/internal/repository"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
|
|
||||||
@ -91,17 +90,7 @@ func rebuildIndex(opts RebuildIndexOptions, gopts GlobalOptions, repo *repositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
Verbosef("getting pack files to read...\n")
|
Verbosef("getting pack files to read...\n")
|
||||||
|
packSizeFromIndex := repo.Index().PackSize(ctx, false)
|
||||||
// Compute size of each pack from index entries
|
|
||||||
packSizeFromIndex := make(map[restic.ID]int64)
|
|
||||||
for blob := range repo.Index().Each(ctx) {
|
|
||||||
size, ok := packSizeFromIndex[blob.PackID]
|
|
||||||
if !ok {
|
|
||||||
size = pack.HeaderSize
|
|
||||||
}
|
|
||||||
// update packSizeFromIndex
|
|
||||||
packSizeFromIndex[blob.PackID] = size + int64(pack.PackedSizeOfBlob(blob.Length))
|
|
||||||
}
|
|
||||||
|
|
||||||
err = repo.List(ctx, restic.PackFile, func(id restic.ID, packSize int64) error {
|
err = repo.List(ctx, restic.PackFile, func(id restic.ID, packSize int64) error {
|
||||||
size, ok := packSizeFromIndex[id]
|
size, ok := packSizeFromIndex[id]
|
||||||
|
Loading…
Reference in New Issue
Block a user