diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-12-01 00:45:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 00:45:11 +0100 |
commit | b0f6b4786b58b4add6e54d354311fc1084764b36 (patch) | |
tree | ebc3ad2f840da271aeac9cf33cc3912feb9f9e12 /storage/memory/storage.go | |
parent | 174fd8e5b2150dbd4cf522bb4a98fb9d79ebc6f4 (diff) | |
parent | d53264806f0d5ddef259f45f4490a19398a102ba (diff) | |
download | go-git-b0f6b4786b58b4add6e54d354311fc1084764b36.tar.gz |
Merge pull request #669 from keybase/strib/gh-gc
storage/repository: add new functions for garbage collection
Diffstat (limited to 'storage/memory/storage.go')
-rw-r--r-- | storage/memory/storage.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go index 927ec41..0f66f1e 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -3,6 +3,7 @@ package memory import ( "fmt" + "time" "gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/plumbing" @@ -114,6 +115,13 @@ func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.H return h, nil } +func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { + if _, ok := o.Objects[h]; !ok { + return plumbing.ErrObjectNotFound + } + return 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) { @@ -156,6 +164,35 @@ func (o *ObjectStorage) Begin() storer.Transaction { } } +func (o *ObjectStorage) ForEachObjectHash(fun func(plumbing.Hash) error) error { + for h, _ := range o.Objects { + err := fun(h) + if err != nil { + if err == storer.ErrStop { + return nil + } + return err + } + } + return nil +} + +func (o *ObjectStorage) ObjectPacks() ([]plumbing.Hash, error) { + return nil, nil +} +func (o *ObjectStorage) DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) error { + return nil +} + +var errNotSupported = fmt.Errorf("Not supported") + +func (s *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) { + return time.Time{}, errNotSupported +} +func (s *ObjectStorage) DeleteLooseObject(plumbing.Hash) error { + return errNotSupported +} + type TxObjectStorage struct { Storage *ObjectStorage Objects map[plumbing.Hash]plumbing.EncodedObject @@ -236,6 +273,14 @@ func (r ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { return storer.NewReferenceSliceIter(refs), nil } +func (r ReferenceStorage) CountLooseRefs() (int, error) { + return len(r), nil +} + +func (r ReferenceStorage) PackRefs() error { + return nil +} + func (r ReferenceStorage) RemoveReference(n plumbing.ReferenceName) error { delete(r, n) return nil |