aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/packfile_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-06-30 09:25:19 +0100
committerGitHub <noreply@github.com>2021-06-30 10:25:19 +0200
commitb4368b2a2ca4103b1ff4e37c34a963127342747e (patch)
tree5a3616045c4be8e7d64706017cf4380f6937ad32 /plumbing/format/packfile/packfile_test.go
parentda810275bf682d29a530ed819aff175f47bd7634 (diff)
downloadgo-git-b4368b2a2ca4103b1ff4e37c34a963127342747e.tar.gz
plumbing: format/packfile, prevent large objects from being read into memory completely (#330)
This PR adds code to prevent large objects from being read into memory from packfiles or the filesystem. Objects greater than 1Mb are now no longer directly stored in the cache or read completely into memory. This PR differs and improves the previous broken #323 by fixing several bugs in the reader and transparently wrapping ReaderAt as a Reader. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'plumbing/format/packfile/packfile_test.go')
-rw-r--r--plumbing/format/packfile/packfile_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/plumbing/format/packfile/packfile_test.go b/plumbing/format/packfile/packfile_test.go
index 60c7c73..6af8817 100644
--- a/plumbing/format/packfile/packfile_test.go
+++ b/plumbing/format/packfile/packfile_test.go
@@ -111,7 +111,7 @@ func (s *PackfileSuite) SetUpTest(c *C) {
s.idx = idxfile.NewMemoryIndex()
c.Assert(idxfile.NewDecoder(s.f.Idx()).Decode(s.idx), IsNil)
- s.p = packfile.NewPackfile(s.idx, fixtures.Filesystem, s.f.Packfile())
+ s.p = packfile.NewPackfile(s.idx, fixtures.Filesystem, s.f.Packfile(), 0)
}
func (s *PackfileSuite) TearDownTest(c *C) {
@@ -122,7 +122,7 @@ func (s *PackfileSuite) TestDecode(c *C) {
fixtures.Basic().ByTag("packfile").Test(c, func(f *fixtures.Fixture) {
index := getIndexFromIdxFile(f.Idx())
- p := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile())
+ p := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile(), 0)
defer p.Close()
for _, h := range expectedHashes {
@@ -138,7 +138,7 @@ func (s *PackfileSuite) TestDecodeByTypeRefDelta(c *C) {
index := getIndexFromIdxFile(f.Idx())
- packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile())
+ packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile(), 0)
defer packfile.Close()
iter, err := packfile.GetByType(plumbing.CommitObject)
@@ -171,7 +171,7 @@ func (s *PackfileSuite) TestDecodeByType(c *C) {
for _, t := range ts {
index := getIndexFromIdxFile(f.Idx())
- packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile())
+ packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile(), 0)
defer packfile.Close()
iter, err := packfile.GetByType(t)
@@ -189,7 +189,7 @@ func (s *PackfileSuite) TestDecodeByTypeConstructor(c *C) {
f := fixtures.Basic().ByTag("packfile").One()
index := getIndexFromIdxFile(f.Idx())
- packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile())
+ packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile(), 0)
defer packfile.Close()
_, err := packfile.GetByType(plumbing.OFSDeltaObject)
@@ -266,7 +266,7 @@ func (s *PackfileSuite) TestSize(c *C) {
index := getIndexFromIdxFile(f.Idx())
- packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile())
+ packfile := packfile.NewPackfile(index, fixtures.Filesystem, f.Packfile(), 0)
defer packfile.Close()
// Get the size of binary.jpg, which is not delta-encoded.