2015-05-13 14:23:49 +00:00
|
|
|
package lfs
|
|
|
|
|
2015-05-14 18:56:30 +00:00
|
|
|
type Downloadable struct {
|
2015-05-27 19:45:18 +00:00
|
|
|
Pointer *WrappedPointer
|
2015-05-21 16:36:49 +00:00
|
|
|
object *objectResource
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 19:45:18 +00:00
|
|
|
func NewDownloadable(p *WrappedPointer) *Downloadable {
|
2015-05-21 16:36:49 +00:00
|
|
|
return &Downloadable{Pointer: p}
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 16:36:49 +00:00
|
|
|
func (d *Downloadable) Check() (*objectResource, *WrappedError) {
|
|
|
|
return DownloadCheck(d.Pointer.Oid)
|
2015-05-14 18:56:30 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 16:36:49 +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 {
|
2015-05-21 16:36:49 +00:00
|
|
|
return Error(err)
|
2015-05-14 18:56:30 +00:00
|
|
|
}
|
2015-05-21 16:36:49 +00:00
|
|
|
return nil
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 16:36:49 +00:00
|
|
|
func (d *Downloadable) Object() *objectResource {
|
|
|
|
return d.object
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 16:36:49 +00:00
|
|
|
func (d *Downloadable) Oid() string {
|
|
|
|
return d.Pointer.Oid
|
|
|
|
}
|
2015-05-13 14:23:49 +00:00
|
|
|
|
2015-05-21 16:36:49 +00:00
|
|
|
func (d *Downloadable) Size() int64 {
|
|
|
|
return d.Pointer.Size
|
|
|
|
}
|
2015-05-13 14:23:49 +00:00
|
|
|
|
2015-06-19 17:59:30 +00:00
|
|
|
func (d *Downloadable) Name() string {
|
|
|
|
return d.Pointer.Name
|
|
|
|
}
|
|
|
|
|
2015-05-21 16:36:49 +00:00
|
|
|
func (d *Downloadable) SetObject(o *objectResource) {
|
|
|
|
d.object = o
|
2015-05-13 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 16:36: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
|
|
|
}
|