git-lfs/lfs/download_queue.go
rubyist 4c9edba6e5 Support concurrent transfers when outputting progress for desktop apps
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.
2015-06-19 13:59:30 -04:00

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
}