mirror of
https://github.com/restic/restic.git
synced 2025-01-03 13:45:20 +00:00
repository: prevent header overfill
This commit is contained in:
parent
6a6d313c9a
commit
1e3f05c3f1
2 changed files with 9 additions and 2 deletions
|
@ -157,6 +157,13 @@ func (p *Packer) Count() int {
|
|||
return len(p.blobs)
|
||||
}
|
||||
|
||||
// HeaderFull returns true if the pack header is full.
|
||||
func (p *Packer) HeaderFull() bool {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
return headerSize+uint(len(p.blobs)+1)*entrySize > MaxHeaderSize
|
||||
}
|
||||
|
||||
// Blobs returns the slice of blobs that have been written.
|
||||
func (p *Packer) Blobs() []restic.Blob {
|
||||
p.m.Lock()
|
||||
|
|
|
@ -87,8 +87,8 @@ func (r *packerManager) SaveBlob(ctx context.Context, t restic.BlobType, id rest
|
|||
return 0, err
|
||||
}
|
||||
|
||||
// if the pack is not full enough, put back to the list
|
||||
if packer.Size() < r.packSize {
|
||||
// if the pack and header is not full enough, put back to the list
|
||||
if packer.Size() < r.packSize && !packer.HeaderFull() {
|
||||
debug.Log("pack is not full enough (%d bytes)", packer.Size())
|
||||
return size, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue