|
| 1 | +package transfer |
| 2 | + |
| 3 | +import ( |
| 4 | + "io" |
| 5 | + "io/fs" |
| 6 | +) |
| 7 | + |
| 8 | +const ( |
| 9 | + // UploadOperation is an upload operation. |
| 10 | + UploadOperation = "upload" |
| 11 | + // DownloadOperation is a download operation. |
| 12 | + DownloadOperation = "download" |
| 13 | +) |
| 14 | + |
| 15 | +// Backend is a Git LFS backend. |
| 16 | +type Backend interface { |
| 17 | + Batch(op string, pointers []BatchItem, args Args) ([]BatchItem, error) |
| 18 | + StartUpload(oid string, r io.Reader, args Args) (io.Closer, error) |
| 19 | + FinishUpload(state io.Closer, args Args) error |
| 20 | + Verify(oid string, args Args) (Status, error) |
| 21 | + Download(oid string, args Args) (fs.File, error) |
| 22 | + LockBackend(args Args) LockBackend |
| 23 | +} |
| 24 | + |
| 25 | +// Lock is a Git LFS lock. |
| 26 | +type Lock interface { |
| 27 | + Unlock() error |
| 28 | + ID() string |
| 29 | + Path() string |
| 30 | + FormattedTimestamp() string |
| 31 | + OwnerName() string |
| 32 | + AsLockSpec(ownerID bool) ([]string, error) |
| 33 | + AsArguments() []string |
| 34 | +} |
| 35 | + |
| 36 | +// LockBackend is a Git LFS lock backend. |
| 37 | +type LockBackend interface { |
| 38 | + // Create creates a lock for the given path and refname. |
| 39 | + // Refname can be empty. |
| 40 | + Create(path, refname string) (Lock, error) |
| 41 | + Unlock(lock Lock) error |
| 42 | + FromPath(path string) (Lock, error) |
| 43 | + FromID(id string) (Lock, error) |
| 44 | + Range(cursor string, limit int, iter func(Lock) error) (string, error) |
| 45 | +} |
0 commit comments