aboutsummaryrefslogtreecommitdiffstats
path: root/packfile/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'packfile/reader.go')
-rw-r--r--packfile/reader.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/packfile/reader.go b/packfile/reader.go
index 73afdb9..627fdfd 100644
--- a/packfile/reader.go
+++ b/packfile/reader.go
@@ -11,6 +11,10 @@ import (
const MaxObjectsLimit = 1000000
+const MaxSizeLimit = 300 * 1 << 20
+
+var ErrMaxSize = fmt.Errorf("Max size exceeded for in-memory client")
+
type TrackingByteReader struct {
r io.Reader
n int
@@ -24,6 +28,9 @@ func (t *TrackingByteReader) Read(p []byte) (n int, err error) {
return 0, err
}
t.n += n
+ if t.n >= MaxSizeLimit {
+ return n, ErrMaxSize
+ }
return n, err
}
@@ -103,6 +110,8 @@ func (pr *PackfileReader) Read() (*Packfile, error) {
return nil, err
}
+ packfile.Size = int64(pr.r.Pos())
+
return packfile, nil
}