git-lfs/lfs/download_queue.go

50 lines
1.0 KiB
Go
Raw Normal View History

2015-05-13 14:23:49 +00:00
package lfs
2015-05-14 18:56:30 +00:00
type Downloadable struct {
Pointer *WrappedPointer
object *objectResource
2015-05-13 14:23:49 +00:00
}
func NewDownloadable(p *WrappedPointer) *Downloadable {
return &Downloadable{Pointer: p}
2015-05-13 14:23:49 +00:00
}
func (d *Downloadable) Check() (*objectResource, *WrappedError) {
return DownloadCheck(d.Pointer.Oid)
2015-05-14 18:56:30 +00:00
}
func (d *Downloadable) Transfer(cb CopyCallback) *WrappedError {
err := PointerSmudgeObject(d.Pointer.Pointer, d.object, cb)
2015-05-14 18:56:30 +00:00
if err != nil {
return Error(err)
2015-05-14 18:56:30 +00:00
}
return nil
2015-05-13 14:23:49 +00:00
}
func (d *Downloadable) Object() *objectResource {
return d.object
2015-05-13 14:23:49 +00:00
}
func (d *Downloadable) Oid() string {
return d.Pointer.Oid
}
2015-05-13 14:23:49 +00:00
func (d *Downloadable) Size() int64 {
return d.Pointer.Size
}
2015-05-13 14:23:49 +00:00
func (d *Downloadable) Name() string {
return d.Pointer.Name
}
func (d *Downloadable) SetObject(o *objectResource) {
d.object = o
2015-05-13 14:23:49 +00:00
}
// NewDownloadQueue builds a DownloadQueue, allowing `workers` concurrent downloads.
func NewDownloadQueue(workers, files int) *TransferQueue {
q := newTransferQueue(workers, files)
q.transferKind = "download"
return q
2015-05-13 14:23:49 +00:00
}