git-lfs/lfs/download_queue.go

58 lines
1.4 KiB
Go
Raw Normal View History

2015-05-13 14:23:49 +00:00
package lfs
import (
"github.com/github/git-lfs/api"
"github.com/github/git-lfs/config"
"github.com/github/git-lfs/transfer"
)
type Downloadable struct {
pointer *WrappedPointer
object *api.ObjectResource
2015-05-13 14:23:49 +00:00
}
func (d *Downloadable) Object() *api.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) Path() string {
p, _ := LocalMediaPath(d.pointer.Oid)
return p
2015-05-13 14:23:49 +00:00
}
func (d *Downloadable) SetObject(o *api.ObjectResource) {
d.object = o
}
// TODO remove this legacy method & only support batch
func (d *Downloadable) LegacyCheck() (*api.ObjectResource, error) {
return api.DownloadCheck(config.Config, d.pointer.Oid)
}
func NewDownloadable(p *WrappedPointer) *Downloadable {
return &Downloadable{pointer: p}
}
// NewDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
func NewDownloadCheckQueue(files int, size int64) *TransferQueue {
// Always dry run
return newTransferQueue(files, size, true, transfer.Download)
}
// NewDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
func NewDownloadQueue(files int, size int64, dryRun bool) *TransferQueue {
return newTransferQueue(files, size, dryRun, transfer.Download)
2015-05-13 14:23:49 +00:00
}