code.gitea.io/gitea@v1.19.3/modules/lfs/client.go (about)

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