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.
This commit is contained in:
Michael Eischer 2022-06-04 23:53:25 +02:00
parent 6c4ceaf1e7
commit 856d5e4303
1 changed files with 3 additions and 3 deletions

View File

@ -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++
}
}