diff options
Diffstat (limited to 'storage/transactional/object.go')
-rw-r--r-- | storage/transactional/object.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/storage/transactional/object.go b/storage/transactional/object.go index 21490b7..beb63d6 100644 --- a/storage/transactional/object.go +++ b/storage/transactional/object.go @@ -5,19 +5,24 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/storer" ) +// ObjectStorage implements the storer.EncodedObjectStorer for the transactional package. type ObjectStorage struct { storer.EncodedObjectStorer temporal storer.EncodedObjectStorer } -func NewObjectStorage(s, temporal storer.EncodedObjectStorer) *ObjectStorage { - return &ObjectStorage{EncodedObjectStorer: s, temporal: temporal} +// NewObjectStorage returns a new EncodedObjectStorer based on a base storer and +// a temporal storer. +func NewObjectStorage(base, temporal storer.EncodedObjectStorer) *ObjectStorage { + return &ObjectStorage{EncodedObjectStorer: base, temporal: temporal} } +// SetEncodedObject honors the storer.EncodedObjectStorer interface. func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) { return o.temporal.SetEncodedObject(obj) } +// HasEncodedObject honors the storer.EncodedObjectStorer interface. func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) error { err := o.EncodedObjectStorer.HasEncodedObject(h) if err == plumbing.ErrObjectNotFound { @@ -27,6 +32,7 @@ func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) error { return err } +// EncodedObjectSize honors the storer.EncodedObjectStorer interface. func (o *ObjectStorage) EncodedObjectSize(h plumbing.Hash) (int64, error) { sz, err := o.EncodedObjectStorer.EncodedObjectSize(h) if err == plumbing.ErrObjectNotFound { @@ -36,6 +42,7 @@ func (o *ObjectStorage) EncodedObjectSize(h plumbing.Hash) (int64, error) { return sz, err } +// EncodedObject honors the storer.EncodedObjectStorer interface. func (o *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) { obj, err := o.EncodedObjectStorer.EncodedObject(t, h) if err == plumbing.ErrObjectNotFound { @@ -45,6 +52,7 @@ func (o *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (p return obj, err } +// IterEncodedObjects honors the storer.EncodedObjectStorer interface. func (o *ObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (storer.EncodedObjectIter, error) { baseIter, err := o.EncodedObjectStorer.IterEncodedObjects(t) if err != nil { @@ -62,6 +70,7 @@ func (o *ObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (storer.Encode }), nil } +// Commit it copies the objects of the temporal storage into the base storage. func (o *ObjectStorage) Commit() error { iter, err := o.temporal.IterEncodedObjects(plumbing.AnyObject) if err != nil { |