1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

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++
}
}
@ -148,7 +155,7 @@ func runStats(gopts GlobalOptions, args []string) error {
}
Printf("Stats in %s mode:\n", statsOptions.countMode)
Printf("Snapshots processed: %d\n", stats.SnapshotsCount)
Printf(" Snapshots processed: %d\n", stats.SnapshotsCount)
if stats.TotalBlobCount > 0 {
Printf(" Total Blob Count: %d\n", 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