debian-mirror-gitlab/workhorse/internal/upload/destination/reader.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
257 B
Go
Raw Normal View History

2022-05-07 20:08:51 +05:30
package destination
2021-02-22 17:27:13 +05:30
import "io"
type hardLimitReader struct {
r io.Reader
n int64
}
func (h *hardLimitReader) Read(p []byte) (int, error) {
nRead, err := h.r.Read(p)
h.n -= int64(nRead)
if h.n < 0 {
err = ErrEntityTooLarge
}
return nRead, err
}