You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package lfs
  4. import (
  5. "context"
  6. "io"
  7. "net/http"
  8. "net/url"
  9. )
  10. // DownloadCallback gets called for every requested LFS object to process its content
  11. type DownloadCallback func(p Pointer, content io.ReadCloser, objectError error) error
  12. // UploadCallback gets called for every requested LFS object to provide its content
  13. type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error)
  14. // Client is used to communicate with a LFS source
  15. type Client interface {
  16. BatchSize() int
  17. Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error
  18. Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error
  19. }
  20. // NewClient creates a LFS client
  21. func NewClient(endpoint *url.URL, httpTransport *http.Transport) Client {
  22. if endpoint.Scheme == "file" {
  23. return newFilesystemClient(endpoint)
  24. }
  25. return newHTTPClient(endpoint, httpTransport)
  26. }