commands: make the tq.Manifest an explicit argument

This commit is contained in:
risk danger olson 2017-01-03 15:23:37 -07:00
parent 4ae792d0b2
commit 40786709a2
5 changed files with 22 additions and 17 deletions

@ -279,7 +279,7 @@ func fetchAndReportToChan(allpointers []*lfs.WrappedPointer, filter *filepathfil
}
ready, pointers, meter := readyAndMissingPointers(allpointers, filter)
q := newDownloadQueue(tq.WithProgress(meter))
q := newDownloadQueue(TransferManifest(), tq.WithProgress(meter))
if out != nil {
// If we already have it, or it won't be fetched

@ -122,7 +122,7 @@ func prune(fetchPruneConfig config.FetchPruneConfig, verifyRemote, dryRun, verbo
if verifyRemote {
cfg.CurrentRemote = fetchPruneConfig.PruneRemoteName
// build queue now, no estimates or progress output
verifyQueue = newDownloadCheckQueue()
verifyQueue = newDownloadCheckQueue(TransferManifest())
verifiedObjects = tools.NewStringSetWithCapacity(len(localObjects) / 2)
// this channel is filled with oids for which Check() succeeded & Transfer() was called

@ -47,7 +47,7 @@ func pull(filter *filepathfilter.Filter) {
pointers := newPointerMap()
meter := progress.NewMeter(progress.WithOSEnv(cfg.Os))
singleCheckout := newSingleCheckout()
q := newDownloadQueue(tq.WithProgress(meter))
q := newDownloadQueue(singleCheckout.manifest, tq.WithProgress(meter))
gitscanner := lfs.NewGitScanner(func(p *lfs.WrappedPointer, err error) {
if err != nil {
LoggedError(err, "Scanner error")

@ -38,6 +38,12 @@ var (
excludeArg string
)
// TransferManifest builds a tq.Manifest from the commands package global
// cfg var.
func TransferManifest() *tq.Manifest {
return lfs.TransferManifest(cfg)
}
func newAPIClient() *lfsapi.Client {
c, err := lfsapi.NewClient(cfg.Os, cfg.Git)
if err != nil {
@ -59,25 +65,22 @@ func newLockClient(remote string) *locking.Client {
return lockClient
}
// TransferManifest builds a tq.Manifest from the commands package global
// cfg var.
func TransferManifest() *tq.Manifest {
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...)
func newDownloadCheckQueue(manifest *tq.Manifest, 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(manifest, allOptions...)
}
// newDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
func newDownloadQueue(options ...tq.Option) *tq.TransferQueue {
return lfs.NewDownloadQueue(cfg, options...)
func newDownloadQueue(manifest *tq.Manifest, options ...tq.Option) *tq.TransferQueue {
return tq.NewTransferQueue(tq.Download, manifest, options...)
}
// newUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
func newUploadQueue(options ...tq.Option) *tq.TransferQueue {
return lfs.NewUploadQueue(cfg, options...)
func newUploadQueue(manifest *tq.Manifest, options ...tq.Option) *tq.TransferQueue {
return tq.NewTransferQueue(tq.Upload, manifest, options...)
}
func buildFilepathFilter(config *config.Configuration, includeArg, excludeArg *string) *filepathfilter.Filter {

@ -13,6 +13,7 @@ var uploadMissingErr = "%s does not exist in .git/lfs/objects. Tried %s, which m
type uploadContext struct {
DryRun bool
manifest *tq.Manifest
uploadedOids tools.StringSet
}
@ -20,6 +21,7 @@ func newUploadContext(dryRun bool) *uploadContext {
return &uploadContext{
DryRun: dryRun,
uploadedOids: tools.NewStringSet(),
manifest: TransferManifest(),
}
}
@ -75,7 +77,7 @@ func (c *uploadContext) prepareUpload(unfiltered []*lfs.WrappedPointer) (*tq.Tra
// build the TransferQueue, automatically skipping any missing objects that
// the server already has.
uploadQueue := newUploadQueue(tq.WithProgress(meter), tq.DryRun(c.DryRun))
uploadQueue := newUploadQueue(c.manifest, tq.WithProgress(meter), tq.DryRun(c.DryRun))
for _, p := range missingLocalObjects {
if c.HasUploaded(p.Oid) {
// if the server already has this object, call Skip() on
@ -99,7 +101,7 @@ func (c *uploadContext) checkMissing(missing []*lfs.WrappedPointer, missingSize
return
}
checkQueue := newDownloadCheckQueue()
checkQueue := newDownloadCheckQueue(c.manifest)
transferCh := checkQueue.Watch()
done := make(chan int)