From 581d90cf910077a0e24ab75d71524106dd347cc0 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 1 May 2020 22:56:34 +0200 Subject: [PATCH] Make some pack parameters public --- internal/pack/pack.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/pack/pack.go b/internal/pack/pack.go index fbe0522dc..d4f064476 100644 --- a/internal/pack/pack.go +++ b/internal/pack/pack.go @@ -161,13 +161,16 @@ func (p *Packer) String() string { } var ( - // size of the header-length field at the end of the file - headerLengthSize = binary.Size(uint32(0)) // we require at least one entry in the header, and one blob for a pack file minFileSize = entrySize + crypto.Extension + uint(headerLengthSize) ) const ( + // size of the header-length field at the end of the file; it is a uint32 + headerLengthSize = 4 + // constant overhead of the header independent of #entries + HeaderSize = headerLengthSize + crypto.Extension + maxHeaderSize = 16 * 1024 * 1024 // number of header enries to download as part of header-length request eagerEntries = 15 @@ -315,3 +318,8 @@ func List(k *crypto.Key, rd io.ReaderAt, size int64) (entries []restic.Blob, err return entries, nil } + +// PackedSizeOfBlob returns the size a blob actually uses when saved in a pack +func PackedSizeOfBlob(blobLength uint) uint { + return blobLength + entrySize +}