MCPcopy Create free account
hub / github.com/coder/coder / projectedTarEntrySize

Function projectedTarEntrySize

archive/archive.go:75–92  ·  view source on GitHub ↗
(file *zip.File)

Source from the content-addressed store, hash-verified

73}
74
75func projectedTarEntrySize(file *zip.File) (uint64, error) {
76 // Each tar entry contributes one header block plus its data
77 // rounded up to the next tar block boundary.
78 size := file.UncompressedSize64
79 if remainder := size % tarBlockSize; remainder != 0 {
80 padding := tarBlockSize - remainder
81 if size > math.MaxUint64-padding {
82 return 0, ErrArchiveTooLarge
83 }
84 size += padding
85 }
86
87 if size > math.MaxUint64-tarBlockSize {
88 return 0, ErrArchiveTooLarge
89 }
90
91 return tarBlockSize + size, nil
92}
93
94type limitedWriter struct {
95 w io.Writer

Callers 1

validateZipArchiveSizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected