move transfer manifest and transfer queue helpers to lfs
This commit is contained in:
parent
21175a923a
commit
fa2fe541ac
@ -44,7 +44,27 @@ var (
|
||||
// TransferManifest builds a tq.Manifest from the commands package global
|
||||
// cfg var.
|
||||
func TransferManifest() *tq.Manifest {
|
||||
return tq.ConfigureManifest(tq.NewManifest(), cfg)
|
||||
return lfs.TransferManifest(cfg)
|
||||
}
|
||||
|
||||
// newDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
|
||||
func newDownloadCheckQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
return lfs.NewDownloadCheckQueue(cfg, options...)
|
||||
}
|
||||
|
||||
// newDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
|
||||
func newDownloadQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
return lfs.NewDownloadQueue(cfg, options...)
|
||||
}
|
||||
|
||||
// newUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
|
||||
func newUploadQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
return lfs.NewUploadQueue(cfg, options...)
|
||||
}
|
||||
|
||||
func buildFilepathFilter(config *config.Configuration, includeArg, excludeArg *string) *filepathfilter.Filter {
|
||||
inc, exc := determineIncludeExcludePaths(config, includeArg, excludeArg)
|
||||
return filepathfilter.New(inc, exc)
|
||||
}
|
||||
|
||||
// Error prints a formatted message to Stderr. It also gets printed to the
|
||||
@ -242,29 +262,6 @@ func logPanicToWriter(w io.Writer, loggedError error) {
|
||||
}
|
||||
}
|
||||
|
||||
// newDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
|
||||
func newDownloadCheckQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
allOptions := make([]tq.Option, len(options), len(options)+1)
|
||||
allOptions = append(allOptions, options...)
|
||||
allOptions = append(allOptions, tq.DryRun(true))
|
||||
return newDownloadQueue(allOptions...)
|
||||
}
|
||||
|
||||
// newDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
|
||||
func newDownloadQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
return tq.NewTransferQueue(tq.Download, TransferManifest(), options...)
|
||||
}
|
||||
|
||||
// newUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
|
||||
func newUploadQueue(options ...tq.Option) *tq.TransferQueue {
|
||||
return tq.NewTransferQueue(tq.Upload, TransferManifest(), options...)
|
||||
}
|
||||
|
||||
func buildFilepathFilter(config *config.Configuration, includeArg, excludeArg *string) *filepathfilter.Filter {
|
||||
inc, exc := determineIncludeExcludePaths(config, includeArg, excludeArg)
|
||||
return filepathfilter.New(inc, exc)
|
||||
}
|
||||
|
||||
func determineIncludeExcludePaths(config *config.Configuration, includeArg, excludeArg *string) (include, exclude []string) {
|
||||
if includeArg == nil {
|
||||
include = config.FetchIncludePaths()
|
||||
|
@ -1,6 +1,10 @@
|
||||
package lfs
|
||||
|
||||
import "github.com/git-lfs/git-lfs/api"
|
||||
import (
|
||||
"github.com/git-lfs/git-lfs/api"
|
||||
"github.com/git-lfs/git-lfs/config"
|
||||
"github.com/git-lfs/git-lfs/tq"
|
||||
)
|
||||
|
||||
type Downloadable struct {
|
||||
pointer *WrappedPointer
|
||||
@ -35,3 +39,16 @@ func (d *Downloadable) SetObject(o *api.ObjectResource) {
|
||||
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(cfg *config.Configuration, options ...tq.Option) *tq.TransferQueue {
|
||||
allOptions := make([]tq.Option, len(options), len(options)+1)
|
||||
allOptions = append(allOptions, options...)
|
||||
allOptions = append(allOptions, tq.DryRun(true))
|
||||
return NewDownloadQueue(cfg, allOptions...)
|
||||
}
|
||||
|
||||
// NewDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
|
||||
func NewDownloadQueue(cfg *config.Configuration, options ...tq.Option) *tq.TransferQueue {
|
||||
return tq.NewTransferQueue(tq.Download, TransferManifest(cfg), options...)
|
||||
}
|
||||
|
@ -118,6 +118,11 @@ func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string {
|
||||
return env
|
||||
}
|
||||
|
||||
// TransferManifest builds a tq.Manifest using the given cfg.
|
||||
func TransferManifest(cfg *config.Configuration) *tq.Manifest {
|
||||
return tq.ConfigureManifest(tq.NewManifest(), cfg)
|
||||
}
|
||||
|
||||
func InRepo() bool {
|
||||
return config.LocalGitDir != ""
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/git-lfs/git-lfs/api"
|
||||
"github.com/git-lfs/git-lfs/config"
|
||||
"github.com/git-lfs/git-lfs/errors"
|
||||
"github.com/git-lfs/git-lfs/tq"
|
||||
)
|
||||
|
||||
// Uploadable describes a file that can be uploaded.
|
||||
@ -101,3 +102,8 @@ func ensureFile(smudgePath, cleanPath string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
|
||||
func NewUploadQueue(cfg *config.Configuration, options ...tq.Option) *tq.TransferQueue {
|
||||
return tq.NewTransferQueue(tq.Upload, TransferManifest(cfg), options...)
|
||||
}
|
||||
|
@ -159,8 +159,7 @@ func buildTestData() (oidsExist, oidsMissing []TestObject, err error) {
|
||||
outputs := repo.AddCommits([]*test.CommitInput{&commit})
|
||||
|
||||
// now upload
|
||||
manifest := tq.ConfigureManifest(tq.NewManifest(), config.Config)
|
||||
uploadQueue := tq.NewTransferQueue(tq.Upload, manifest, tq.WithProgress(meter))
|
||||
uploadQueue := lfs.NewUploadQueue(config.Config, tq.WithProgress(meter))
|
||||
for _, f := range outputs[0].Files {
|
||||
oidsExist = append(oidsExist, TestObject{Oid: f.Oid, Size: f.Size})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user