Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit a201412

Browse files
committed
memory passed to NewGit(), changed git types name
1 parent 77906b6 commit a201412

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packfile/reader.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import (
1111

1212
const MaxObjectsLimit = 1000000
1313

14-
const MaxSizeLimit = 300 * 1 << 20
15-
1614
var ErrMaxSize = fmt.Errorf("Max size exceeded for in-memory client")
1715

1816
type TrackingByteReader struct {
19-
r io.Reader
20-
n int
17+
r io.Reader
18+
n, l int
2119
}
2220

2321
func (t *TrackingByteReader) Pos() int { return t.n }
@@ -28,7 +26,7 @@ func (t *TrackingByteReader) Read(p []byte) (n int, err error) {
2826
return 0, err
2927
}
3028
t.n += n
31-
if t.n >= MaxSizeLimit {
29+
if t.n >= t.l {
3230
return n, ErrMaxSize
3331
}
3432
return n, err
@@ -67,9 +65,9 @@ type packfileDelta struct {
6765
delta []byte
6866
}
6967

70-
func NewPackfileReader(r io.Reader, fn ContentCallback) (*PackfileReader, error) {
68+
func NewPackfileReader(r io.Reader, l int, fn ContentCallback) (*PackfileReader, error) {
7169
return &PackfileReader{
72-
r: &TrackingByteReader{r: r, n: 0},
70+
r: &TrackingByteReader{r: r, n: 0, l: l},
7371
objects: make(map[string]packfileObject, 0),
7472
offsets: make(map[int]string, 0),
7573
contentCallback: fn,

packfile/reader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestReadPackfile(t *testing.T) {
1414
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
1515
d := bytes.NewReader(data)
1616

17-
r, err := NewPackfileReader(d, nil)
17+
r, err := NewPackfileReader(d, 8<<20, nil)
1818
assert.Nil(t, err)
1919

2020
p, err := r.Read()
@@ -26,7 +26,7 @@ func TestReadPackfile(t *testing.T) {
2626
}
2727

2828
func TestReadPackfileInvalid(t *testing.T) {
29-
r, err := NewPackfileReader(bytes.NewReader([]byte("dasdsadasas")), nil)
29+
r, err := NewPackfileReader(bytes.NewReader([]byte("dasdsadasas")), 8<<20, nil)
3030
assert.Nil(t, err)
3131

3232
_, err = r.Read()

0 commit comments

Comments
 (0)