From 856d5e430328b1921f5d18c95e50dd62bf17ed84 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 4 Jun 2022 23:53:25 +0200 Subject: [PATCH] stats: return storage size for raw-data mode raw-data summed up the size of the blob plaintexts. However, with compression this makes little sense as the storage size in the repository is lower due to compression. Thus sum up the actual size each blob takes in the repository. --- cmd/restic/cmd_stats.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index b8dcac2a3..b8281034b 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -130,11 +130,11 @@ func runStats(gopts GlobalOptions, args []string) error { if statsOptions.countMode == countModeRawData { // the blob handles have been collected, but not yet counted for blobHandle := range stats.blobs { - blobSize, found := repo.LookupBlobSize(blobHandle.ID, blobHandle.Type) - if !found { + pbs := repo.Index().Lookup(blobHandle) + if len(pbs) == 0 { return fmt.Errorf("blob %v not found", blobHandle) } - stats.TotalSize += uint64(blobSize) + stats.TotalSize += uint64(pbs[0].Length) stats.TotalBlobCount++ } }