Skip to content

Commit

Permalink
prevent anyone from accidentally setting the blocksize to zero
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <avi@deitcher.net>
  • Loading branch information
deitch committed Nov 10, 2020
1 parent d2037e9 commit 098c752
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/content/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ func WithOutputHash(hash digest.Digest) WriterOpt {
}

// WithBlocksize set the blocksize used by the processor of data.
// The default is DefaultBlocksize, which is the same as that used by io.Copy
// The default is DefaultBlocksize, which is the same as that used by io.Copy.
// Includes a safety check to ensure the caller doesn't actively set it to <= 0.
func WithBlocksize(blocksize int) WriterOpt {
return func(w *WriterOpts) error {
w.Blocksize = blocksize
if blocksize > 0 {
w.Blocksize = blocksize
}
return nil
}
}

0 comments on commit 098c752

Please sign in to comment.