aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/decoder.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-11 18:07:29 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-11 18:07:29 +0200
commit1f64d789038594098ea2c9cf796391f101d0bea5 (patch)
tree50fb530fc2e48560e70489dc81758f54822dcf50 /formats/packfile/decoder.go
parentc1e277a7ca75ff84741d75ad45e29a2ff3e633e3 (diff)
downloadgo-git-1f64d789038594098ea2c9cf796391f101d0bea5.tar.gz
core: new MemoryObject, move from memory.Object, packfile.Parser, base on new ObjectStorage interface
Diffstat (limited to 'formats/packfile/decoder.go')
-rw-r--r--formats/packfile/decoder.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/formats/packfile/decoder.go b/formats/packfile/decoder.go
index 2b5ef88..6d0cd8b 100644
--- a/formats/packfile/decoder.go
+++ b/formats/packfile/decoder.go
@@ -35,21 +35,8 @@ var (
ErrZLib = NewError("zlib reading error")
)
-const (
- // DefaultMaxObjectsLimit is the maximum amount of objects the
- // decoder will decode before returning ErrMaxObjectsLimitReached.
- DefaultMaxObjectsLimit = 1 << 20
-)
-
// Decoder reads and decodes packfiles from an input stream.
type Decoder struct {
- // MaxObjectsLimit is the limit of objects to be load in the packfile, if
- // a packfile excess this number an error is throw, the default value
- // is defined by DefaultMaxObjectsLimit, usually the default limit is more
- // than enough to work with any repository, with higher values and huge
- // repositories you can run out of memory.
- MaxObjectsLimit uint32
-
p *Parser
s core.ObjectStorage
}
@@ -57,8 +44,6 @@ type Decoder struct {
// NewDecoder returns a new Decoder that reads from r.
func NewDecoder(r ReadRecaller) *Decoder {
return &Decoder{
- MaxObjectsLimit: DefaultMaxObjectsLimit,
-
p: NewParser(r),
}
}
@@ -72,13 +57,7 @@ func (d *Decoder) Decode(s core.ObjectStorage) error {
return err
}
- if count > d.MaxObjectsLimit {
- return ErrMaxObjectsLimitReached.AddDetails("%d", count)
- }
-
- err = d.readObjects(count)
-
- return err
+ return d.readObjects(count)
}
func (d *Decoder) readObjects(count uint32) error {
@@ -92,8 +71,8 @@ func (d *Decoder) readObjects(count uint32) error {
return err
}
- obj, err := d.p.ReadObject()
- if err != nil {
+ obj := d.s.NewObject()
+ if err := d.p.FillObject(obj); err != nil {
if err == io.EOF {
break
}