From d66e755ac70f3a11170e43e41236672a08f3f9a2 Mon Sep 17 00:00:00 2001 From: plumbeo Date: Wed, 7 Sep 2022 10:09:59 +0200 Subject: [PATCH] Change uncompressed size calculation to account for the encryption overhead --- cmd/restic/cmd_stats.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index 5f089d926..d74ec6a10 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -7,6 +7,7 @@ import ( "path/filepath" "github.com/restic/restic/internal/backend" + "github.com/restic/restic/internal/crypto" "github.com/restic/restic/internal/restic" "github.com/restic/restic/internal/walker" @@ -136,11 +137,7 @@ func runStats(gopts GlobalOptions, args []string) error { } stats.TotalSize += uint64(pbs[0].Length) if repo.Config().Version >= 2 { - if pbs[0].IsCompressed() { - stats.TotalUncompressedSize += uint64(pbs[0].UncompressedLength) - } else { - stats.TotalUncompressedSize += uint64(pbs[0].Length) - } + stats.TotalUncompressedSize += uint64(crypto.CiphertextLength(int(pbs[0].DataLength()))) } stats.TotalBlobCount++ } @@ -293,7 +290,7 @@ func verifyStatsInput(gopts GlobalOptions, args []string) error { // for a successful and efficient walk. type statsContainer struct { TotalSize uint64 `json:"total_size"` - TotalUncompressedSize uint64 `json:"total_uncompressed_size"` + TotalUncompressedSize uint64 `json:"total_uncompressed_size,omitempty"` TotalFileCount uint64 `json:"total_file_count"` TotalBlobCount uint64 `json:"total_blob_count,omitempty"` // holds count of all considered snapshots