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.

client.go 1.0KB

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