2015-05-13 14:23:49 +00:00
|
|
|
package lfs
|
|
|
|
|
2016-05-16 11:31:23 +00:00
|
|
|
import (
|
|
|
|
"github.com/github/git-lfs/api"
|
2016-05-25 15:41:47 +00:00
|
|
|
"github.com/github/git-lfs/transfer"
|
2016-05-16 11:31:23 +00:00
|
|
|
)
|
2016-05-06 14:04:47 +00:00
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
type Downloadable struct {
|
|
|
|
pointer *WrappedPointer
|
2016-05-16 11:31:23 +00:00
|
|
|
object *api.ObjectResource
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) Object() *api.ObjectResource {
|
2015-05-21 16:36:49 +00:00
|
|
|
return d.object
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) Oid() string {
|
|
|
|
return d.pointer.Oid
|
2015-05-21 16:36:49 +00:00
|
|
|
}
|
2015-05-13 14:23:49 +00:00
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) Size() int64 {
|
|
|
|
return d.pointer.Size
|
2015-05-21 16:36:49 +00:00
|
|
|
}
|
2015-05-13 14:23:49 +00:00
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) Name() string {
|
|
|
|
return d.pointer.Name
|
2015-06-19 17:59:30 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) Path() string {
|
|
|
|
p, _ := LocalMediaPath(d.pointer.Oid)
|
|
|
|
return p
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
func (d *Downloadable) SetObject(o *api.ObjectResource) {
|
|
|
|
d.object = o
|
2015-08-13 08:33:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
// TODO remove this legacy method & only support batch
|
|
|
|
func (d *Downloadable) LegacyCheck() (*api.ObjectResource, error) {
|
|
|
|
return api.DownloadCheck(d.pointer.Oid)
|
2015-08-13 08:33:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewDownloadable(p *WrappedPointer) *Downloadable {
|
2016-05-25 15:41:47 +00:00
|
|
|
return &Downloadable{pointer: p}
|
2015-08-13 08:33:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
// NewDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
|
|
|
|
func NewDownloadCheckQueue(files int, size int64) *TransferQueue {
|
|
|
|
// Always dry run
|
2016-06-01 16:33:01 +00:00
|
|
|
return newTransferQueue(files, size, true, transfer.Download)
|
2015-08-13 08:33:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 15:41:47 +00:00
|
|
|
// NewDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
|
2015-07-30 14:43:50 +00:00
|
|
|
func NewDownloadQueue(files int, size int64, dryRun bool) *TransferQueue {
|
2016-06-01 16:33:01 +00:00
|
|
|
return newTransferQueue(files, size, dryRun, transfer.Download)
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|