diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2018-10-11 16:24:25 -0700 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2018-10-11 17:12:21 -0700 |
commit | 1e1315d5e587d481e73e295dd18e50026af48c79 (patch) | |
tree | 5819d378bc667a0f39d51abc230fc678828d5234 /storage/memory | |
parent | 0bfe038a16551ede1d22bfb54f52c31b646a9e1a (diff) | |
download | go-git-1e1315d5e587d481e73e295dd18e50026af48c79.tar.gz |
object: get object size without reading whole object
Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
Diffstat (limited to 'storage/memory')
-rw-r--r-- | storage/memory/storage.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go index 2e32509..6e11742 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -122,6 +122,16 @@ func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { return nil } +func (o *ObjectStorage) EncodedObjectSize(h plumbing.Hash) ( + size int64, err error) { + obj, ok := o.Objects[h] + if !ok { + return 0, plumbing.ErrObjectNotFound + } + + return obj.Size(), nil +} + func (o *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) { obj, ok := o.Objects[h] if !ok || (plumbing.AnyObject != t && obj.Type() != t) { |