mirror of
https://github.com/restic/restic.git
synced 2026-06-06 08:59:44 +00:00
repository: add PackBlob.UncompressedCiphertextLength()
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/restic/chunker"
|
||||
"github.com/restic/restic/internal/crypto"
|
||||
"github.com/restic/restic/internal/data"
|
||||
"github.com/restic/restic/internal/global"
|
||||
"github.com/restic/restic/internal/repository"
|
||||
@@ -168,10 +167,10 @@ func runStats(ctx context.Context, opts StatsOptions, gopts global.Options, args
|
||||
}
|
||||
stats.TotalSize += uint64(pbs[0].CiphertextLength())
|
||||
if repo.Config().Version >= 2 {
|
||||
stats.TotalUncompressedSize += uint64(crypto.CiphertextLength(int(pbs[0].PlaintextLength())))
|
||||
stats.TotalUncompressedSize += uint64(pbs[0].UncompressedCiphertextLength())
|
||||
if pbs[0].IsCompressed() {
|
||||
stats.TotalCompressedBlobsSize += uint64(pbs[0].CiphertextLength())
|
||||
stats.TotalCompressedBlobsUncompressedSize += uint64(crypto.CiphertextLength(int(pbs[0].PlaintextLength())))
|
||||
stats.TotalCompressedBlobsUncompressedSize += uint64(pbs[0].UncompressedCiphertextLength())
|
||||
}
|
||||
}
|
||||
stats.TotalBlobCount++
|
||||
|
||||
@@ -27,6 +27,10 @@ func (b Blob) DataLength() uint {
|
||||
return uint(crypto.PlaintextLength(int(b.Length)))
|
||||
}
|
||||
|
||||
func (b Blob) UncompressedCiphertextLength() uint {
|
||||
return uint(crypto.CiphertextLength(int(b.DataLength())))
|
||||
}
|
||||
|
||||
func (b Blob) IsCompressed() bool {
|
||||
return b.UncompressedLength != 0
|
||||
}
|
||||
|
||||
@@ -8,12 +8,18 @@ type PackedBlob struct {
|
||||
Blob Blob
|
||||
}
|
||||
|
||||
var _ restic.PackBlob = (*PackedBlob)(nil)
|
||||
|
||||
func (pb *PackedBlob) PackID() restic.ID { return pb.Pack }
|
||||
|
||||
func (pb *PackedBlob) Handle() restic.BlobHandle { return pb.Blob.BlobHandle }
|
||||
|
||||
func (pb *PackedBlob) CiphertextLength() uint { return pb.Blob.Length }
|
||||
|
||||
func (pb *PackedBlob) UncompressedCiphertextLength() uint {
|
||||
return pb.Blob.UncompressedCiphertextLength()
|
||||
}
|
||||
|
||||
func (pb *PackedBlob) PlaintextLength() uint { return pb.Blob.DataLength() }
|
||||
|
||||
func (pb *PackedBlob) IsCompressed() bool { return pb.Blob.IsCompressed() }
|
||||
|
||||
@@ -14,6 +14,8 @@ type PackBlob interface {
|
||||
Handle() BlobHandle
|
||||
// CiphertextLength is the encrypted size stored in the pack.
|
||||
CiphertextLength() uint
|
||||
// UncompressedCiphertextLength is the encrypted size of the uncompressed blob.
|
||||
UncompressedCiphertextLength() uint
|
||||
// PlaintextLength is the size after decryption/decompression.
|
||||
PlaintextLength() uint
|
||||
IsCompressed() bool
|
||||
|
||||
@@ -47,6 +47,8 @@ func (pb *testPackBlob) Handle() restic.BlobHandle { return pb.handle }
|
||||
|
||||
func (pb *testPackBlob) CiphertextLength() uint { return pb.ciphertext }
|
||||
|
||||
func (pb *testPackBlob) UncompressedCiphertextLength() uint { return pb.ciphertext }
|
||||
|
||||
func (pb *testPackBlob) PlaintextLength() uint { return pb.plaintext }
|
||||
|
||||
func (pb *testPackBlob) IsCompressed() bool { return pb.compressed }
|
||||
|
||||
Reference in New Issue
Block a user