Skip to content

Commit 70c65ec

Browse files
modules/lfs: add GetMeta method to ContentStore
A download command in the SSH protocol doesn't specify size, so this was necessary.
1 parent 202088f commit 70c65ec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

modules/lfs/content_store.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
)
1717

1818
var (
19+
// ErrObjectNotInStore occurs if the OID is not in store
20+
ErrObjectNotInStore = errors.New("content hash does not match OID")
1921
// ErrHashMismatch occurs if the content has does not match OID
2022
ErrHashMismatch = errors.New("content hash does not match OID")
2123
// ErrSizeMismatch occurs if the content size does not match
@@ -89,6 +91,20 @@ func (s *ContentStore) Exists(pointer Pointer) (bool, error) {
8991
return true, nil
9092
}
9193

94+
// GetMeta takes OID and returns true if the object exists in the content store.
95+
func (s *ContentStore) GetMeta(pointer Pointer) (Pointer, error) {
96+
p := pointer.RelativePath()
97+
fi, err := s.ObjectStorage.Stat(p)
98+
if os.IsNotExist(err) {
99+
return pointer, ErrObjectNotInStore
100+
} else if err != nil {
101+
log.Error("Unable stat file: %s for LFS OID[%s] Error: %v", p, pointer.Oid, err)
102+
return pointer, err
103+
}
104+
pointer.Size = fi.Size()
105+
return pointer, nil
106+
}
107+
92108
// Verify returns true if the object exists in the content store and size is correct.
93109
func (s *ContentStore) Verify(pointer Pointer) (bool, error) {
94110
p := pointer.RelativePath()

0 commit comments

Comments
 (0)