restic stats: print uncompressed size in mode raw-data

This commit is contained in:
plumbeo 2022-09-05 14:18:12 +02:00
parent 6c69f08a7b
commit 837b816358

View file

@ -135,6 +135,13 @@ func runStats(gopts GlobalOptions, args []string) error {
return fmt.Errorf("blob %v not found", blobHandle)
}
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.TotalBlobCount++
}
}
@ -156,6 +163,9 @@ func runStats(gopts GlobalOptions, args []string) error {
if stats.TotalFileCount > 0 {
Printf(" Total File Count: %d\n", stats.TotalFileCount)
}
if stats.TotalUncompressedSize > 0 {
Printf("Total Uncompressed Size: %-5s\n", formatBytes(stats.TotalUncompressedSize))
}
Printf(" Total Size: %-5s\n", formatBytes(stats.TotalSize))
return nil
@ -283,6 +293,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"`
TotalFileCount uint64 `json:"total_file_count"`
TotalBlobCount uint64 `json:"total_blob_count,omitempty"`
// holds count of all considered snapshots