store.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package lfs
  2. import (
  3. "context"
  4. "gogs.io/gogs/internal/database"
  5. )
  6. // Store is the data layer carrier for LFS endpoints. This interface is meant to
  7. // abstract away and limit the exposure of the underlying data layer to the
  8. // handler through a thin-wrapper.
  9. type Store interface {
  10. // GetAccessTokenBySHA1 returns the access token with given SHA1. It returns
  11. // database.ErrAccessTokenNotExist when not found.
  12. GetAccessTokenBySHA1(ctx context.Context, sha1 string) (*database.AccessToken, error)
  13. // TouchAccessTokenByID updates the updated time of the given access token to
  14. // the current time.
  15. TouchAccessTokenByID(ctx context.Context, id int64) error
  16. }
  17. type store struct{}
  18. // NewStore returns a new Store using the global database handle.
  19. func NewStore() Store {
  20. return &store{}
  21. }
  22. func (*store) GetAccessTokenBySHA1(ctx context.Context, sha1 string) (*database.AccessToken, error) {
  23. return database.Handle.AccessTokens().GetBySHA1(ctx, sha1)
  24. }
  25. func (*store) TouchAccessTokenByID(ctx context.Context, id int64) error {
  26. return database.Handle.AccessTokens().Touch(ctx, id)
  27. }