4c9edba6e5
This is a fix for a bug in the handling of the GIT_LFS_PROGRESS file which is used by desktop apps, or other things integrating with the git-lfs binary. At a later point, we should move toward a more unified progress tracking which supports this file as well as the pb progress bars via a single API.
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package lfs
|
|
|
|
type Downloadable struct {
|
|
Pointer *WrappedPointer
|
|
object *objectResource
|
|
}
|
|
|
|
func NewDownloadable(p *WrappedPointer) *Downloadable {
|
|
return &Downloadable{Pointer: p}
|
|
}
|
|
|
|
func (d *Downloadable) Check() (*objectResource, *WrappedError) {
|
|
return DownloadCheck(d.Pointer.Oid)
|
|
}
|
|
|
|
func (d *Downloadable) Transfer(cb CopyCallback) *WrappedError {
|
|
err := PointerSmudgeObject(d.Pointer.Pointer, d.object, cb)
|
|
if err != nil {
|
|
return Error(err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (d *Downloadable) Object() *objectResource {
|
|
return d.object
|
|
}
|
|
|
|
func (d *Downloadable) Oid() string {
|
|
return d.Pointer.Oid
|
|
}
|
|
|
|
func (d *Downloadable) Size() int64 {
|
|
return d.Pointer.Size
|
|
}
|
|
|
|
func (d *Downloadable) Name() string {
|
|
return d.Pointer.Name
|
|
}
|
|
|
|
func (d *Downloadable) SetObject(o *objectResource) {
|
|
d.object = o
|
|
}
|
|
|
|
// NewDownloadQueue builds a DownloadQueue, allowing `workers` concurrent downloads.
|
|
func NewDownloadQueue(workers, files int) *TransferQueue {
|
|
q := newTransferQueue(workers, files)
|
|
q.transferKind = "download"
|
|
return q
|
|
}
|