MCPcopy Create free account
hub / github.com/gogs/gogs / GetObjectByOID

Method GetObjectByOID

internal/database/lfs.go:62–72  ·  view source on GitHub ↗

GetObjectByOID returns the LFS object with given OID. It returns ErrLFSObjectNotExist when not found.

(ctx context.Context, repoID int64, oid lfsutil.OID)

Source from the content-addressed store, hash-verified

60// GetObjectByOID returns the LFS object with given OID. It returns
61// ErrLFSObjectNotExist when not found.
62func (s *LFSStore) GetObjectByOID(ctx context.Context, repoID int64, oid lfsutil.OID) (*LFSObject, error) {
63 object := new(LFSObject)
64 err := s.db.WithContext(ctx).Where("repo_id = ? AND oid = ?", repoID, oid).First(object).Error
65 if err != nil {
66 if errors.Is(err, gorm.ErrRecordNotFound) {
67 return nil, ErrLFSObjectNotExist{args: errutil.Args{"repoID": repoID, "oid": oid}}
68 }
69 return nil, err
70 }
71 return object, err
72}
73
74// GetObjectsByOIDs returns LFS objects found within "oids". The returned list
75// could have fewer elements if some oids were not found.

Callers 3

lfsCreateObjectFunction · 0.80
lfsGetObjectByOIDFunction · 0.80
GetLFSObjectByOIDMethod · 0.80

Calls 1

WhereMethod · 0.80

Tested by 2

lfsCreateObjectFunction · 0.64
lfsGetObjectByOIDFunction · 0.64