aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/storer
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2017-09-22 21:14:17 -0700
committerJeremy Stribling <strib@alum.mit.edu>2017-11-29 11:01:41 -0800
commitaa092f5474da3e9c3ff4f40b88849726b645f39f (patch)
tree08655a5576a113c2946b5eac2ca801b3f5eece6f /plumbing/storer
parent2de4f034288bac895b0a87dcfb5cc3a2f9026f43 (diff)
downloadgo-git-aa092f5474da3e9c3ff4f40b88849726b645f39f.tar.gz
plumbing: add `HasEncodedObject` method to Storer
This allows the user to check whether an object exists, without reading all the object data from storage. Issue: KBFS-2445
Diffstat (limited to 'plumbing/storer')
-rw-r--r--plumbing/storer/object_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/plumbing/storer/object_test.go b/plumbing/storer/object_test.go
index da0db81..9a6959d 100644
--- a/plumbing/storer/object_test.go
+++ b/plumbing/storer/object_test.go
@@ -133,6 +133,15 @@ func (o *MockObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbi
return plumbing.ZeroHash, nil
}
+func (o *MockObjectStorage) HasEncodedObject(h plumbing.Hash) error {
+ for _, o := range o.db {
+ if o.Hash() == h {
+ return nil
+ }
+ }
+ return plumbing.ErrObjectNotFound
+}
+
func (o *MockObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) {
for _, o := range o.db {
if o.Hash() == h {