git-lfs/lfs/download_queue.go
rubyist ebc81aedb9 Run update-index as a single background process
Reorganize the transfer queue to provide a channel to watch for object
OIDs as they finish. This can be used in the `get` command to feed a
goroutine that will copy the file to the working directory and inform
the update-index process about it as the transfers finish. This leads to
a greatly reduced amount of time spent updating the index after a get.
2015-05-27 15:52:28 -04:00

46 lines
965 B
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) 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
}