diff --git a/commands/commands.go b/commands/commands.go index 1050969a..43f55904 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -19,7 +19,7 @@ import ( "github.com/git-lfs/git-lfs/lfs" "github.com/git-lfs/git-lfs/progress" "github.com/git-lfs/git-lfs/tools" - "github.com/git-lfs/git-lfs/transfer" + "github.com/git-lfs/git-lfs/tq" ) // Populate man pages @@ -41,10 +41,10 @@ var ( excludeArg string ) -// TransferManifest builds a transfer.Manifest from the commands package global +// TransferManifest builds a tq.Manifest from the commands package global // cfg var. -func TransferManifest() *transfer.Manifest { - return transfer.ConfigureManifest(transfer.NewManifest(), cfg) +func TransferManifest() *tq.Manifest { + return tq.ConfigureManifest(tq.NewManifest(), cfg) } // Error prints a formatted message to Stderr. It also gets printed to the diff --git a/lfs/download_queue.go b/lfs/download_queue.go index f387dd31..c1b76e13 100644 --- a/lfs/download_queue.go +++ b/lfs/download_queue.go @@ -3,7 +3,6 @@ package lfs import ( "github.com/git-lfs/git-lfs/api" "github.com/git-lfs/git-lfs/tq" - "github.com/git-lfs/git-lfs/transfer" ) type Downloadable struct { @@ -42,10 +41,10 @@ func NewDownloadable(p *WrappedPointer) *Downloadable { // NewDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download func NewDownloadCheckQueue(options ...tq.TransferQueueOption) *tq.TransferQueue { - return tq.NewTransferQueue(transfer.Download, options...) + return tq.NewTransferQueue(tq.Download, options...) } // NewDownloadQueue builds a DownloadQueue, allowing concurrent downloads. func NewDownloadQueue(options ...tq.TransferQueueOption) *tq.TransferQueue { - return tq.NewTransferQueue(transfer.Download, options...) + return tq.NewTransferQueue(tq.Download, options...) } diff --git a/lfs/lfs.go b/lfs/lfs.go index 5e3db25d..ee11c0ef 100644 --- a/lfs/lfs.go +++ b/lfs/lfs.go @@ -12,7 +12,7 @@ import ( "github.com/git-lfs/git-lfs/config" "github.com/git-lfs/git-lfs/localstorage" "github.com/git-lfs/git-lfs/tools" - "github.com/git-lfs/git-lfs/transfer" + "github.com/git-lfs/git-lfs/tq" "github.com/rubyist/tracerx" ) @@ -63,7 +63,7 @@ func ObjectExistsOfSize(oid string, size int64) bool { return tools.FileExistsOfSize(path, size) } -func Environ(cfg *config.Configuration, manifest *transfer.Manifest) []string { +func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string { osEnviron := os.Environ() env := make([]string, 0, len(osEnviron)+7) diff --git a/lfs/pointer.go b/lfs/pointer.go index 9f330b96..d75b88c4 100644 --- a/lfs/pointer.go +++ b/lfs/pointer.go @@ -13,7 +13,7 @@ import ( "github.com/git-lfs/git-lfs/errors" "github.com/git-lfs/git-lfs/progress" - "github.com/git-lfs/git-lfs/transfer" + "github.com/git-lfs/git-lfs/tq" ) var ( @@ -60,7 +60,7 @@ func NewPointerExtension(name string, priority int, oid string) *PointerExtensio return &PointerExtension{name, priority, oid, oidType} } -func (p *Pointer) Smudge(writer io.Writer, workingfile string, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error { +func (p *Pointer) Smudge(writer io.Writer, workingfile string, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error { return PointerSmudge(writer, p, workingfile, download, manifest, cb) } diff --git a/lfs/pointer_smudge.go b/lfs/pointer_smudge.go index 17595e05..3c5ea905 100644 --- a/lfs/pointer_smudge.go +++ b/lfs/pointer_smudge.go @@ -8,7 +8,7 @@ import ( "github.com/cheggaaa/pb" "github.com/git-lfs/git-lfs/tools" - "github.com/git-lfs/git-lfs/transfer" + "github.com/git-lfs/git-lfs/tq" "github.com/git-lfs/git-lfs/api" "github.com/git-lfs/git-lfs/config" @@ -17,7 +17,7 @@ import ( "github.com/rubyist/tracerx" ) -func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error { +func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error { os.MkdirAll(filepath.Dir(filename), 0755) file, err := os.Create(filename) if err != nil { @@ -37,7 +37,7 @@ func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest return nil } -func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error { +func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error { mediafile, err := LocalMediaPath(ptr.Oid) if err != nil { return err @@ -72,7 +72,7 @@ func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download return nil } -func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string, manifest *transfer.Manifest, cb progress.CopyCallback) error { +func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string, manifest *tq.Manifest, cb progress.CopyCallback) error { fmt.Fprintf(os.Stderr, "Downloading %s (%s)\n", workingfile, pb.FormatBytes(ptr.Size)) xfers := manifest.GetDownloadAdapterNames() @@ -86,19 +86,19 @@ func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string, } adapter := manifest.NewDownloadAdapter(adapterName) - var tcb transfer.TransferProgressCallback + var tcb tq.TransferProgressCallback if cb != nil { tcb = func(name string, totalSize, readSoFar int64, readSinceLast int) error { return cb(totalSize, readSoFar, readSinceLast) } } // Single download - adapterResultChan := make(chan transfer.TransferResult, 1) + adapterResultChan := make(chan tq.TransferResult, 1) err = adapter.Begin(1, tcb, adapterResultChan) if err != nil { return err } - adapter.Add(transfer.NewTransfer(filepath.Base(workingfile), obj, mediafile)) + adapter.Add(tq.NewTransfer(filepath.Base(workingfile), obj, mediafile)) adapter.End() res := <-adapterResultChan diff --git a/lfs/upload_queue.go b/lfs/upload_queue.go index 8ef88d77..b0934d84 100644 --- a/lfs/upload_queue.go +++ b/lfs/upload_queue.go @@ -9,7 +9,6 @@ import ( "github.com/git-lfs/git-lfs/config" "github.com/git-lfs/git-lfs/errors" "github.com/git-lfs/git-lfs/tq" - "github.com/git-lfs/git-lfs/transfer" ) // Uploadable describes a file that can be uploaded. @@ -69,7 +68,7 @@ func NewUploadable(oid, filename string) (*Uploadable, error) { // NewUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads. func NewUploadQueue(options ...tq.TransferQueueOption) *tq.TransferQueue { - return tq.NewTransferQueue(transfer.Upload, options...) + return tq.NewTransferQueue(tq.Upload, options...) } // ensureFile makes sure that the cleanPath exists before pushing it. If it diff --git a/transfer/adapterbase.go b/tq/adapterbase.go similarity index 99% rename from transfer/adapterbase.go rename to tq/adapterbase.go index 5205ab24..95574591 100644 --- a/transfer/adapterbase.go +++ b/tq/adapterbase.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "fmt" diff --git a/transfer/basic_download.go b/tq/basic_download.go similarity index 99% rename from transfer/basic_download.go rename to tq/basic_download.go index 7232190c..0dc809e8 100644 --- a/transfer/basic_download.go +++ b/tq/basic_download.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "fmt" diff --git a/transfer/basic_upload.go b/tq/basic_upload.go similarity index 99% rename from transfer/basic_upload.go rename to tq/basic_upload.go index 67fcc761..440a462e 100644 --- a/transfer/basic_upload.go +++ b/tq/basic_upload.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "fmt" diff --git a/transfer/custom.go b/tq/custom.go similarity index 99% rename from transfer/custom.go rename to tq/custom.go index d97740e8..9fd4ab8a 100644 --- a/transfer/custom.go +++ b/tq/custom.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "bufio" diff --git a/transfer/custom_test.go b/tq/custom_test.go similarity index 99% rename from transfer/custom_test.go rename to tq/custom_test.go index 25916d4d..dbc034ff 100644 --- a/transfer/custom_test.go +++ b/tq/custom_test.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "testing" diff --git a/transfer/manifest.go b/tq/manifest.go similarity index 99% rename from transfer/manifest.go rename to tq/manifest.go index a706680b..247dedd8 100644 --- a/transfer/manifest.go +++ b/tq/manifest.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "sync" diff --git a/transfer/transfer.go b/tq/transfer.go similarity index 99% rename from transfer/transfer.go rename to tq/transfer.go index ee649b2d..d2bb122b 100644 --- a/transfer/transfer.go +++ b/tq/transfer.go @@ -1,6 +1,6 @@ // Package transfer collects together adapters for uploading and downloading LFS content // NOTE: Subject to change, do not rely on this package from outside git-lfs source -package transfer +package tq import "github.com/git-lfs/git-lfs/api" diff --git a/tq/transfer_queue.go b/tq/transfer_queue.go index efaaa6cd..3592bbc2 100644 --- a/tq/transfer_queue.go +++ b/tq/transfer_queue.go @@ -8,7 +8,6 @@ import ( "github.com/git-lfs/git-lfs/config" "github.com/git-lfs/git-lfs/errors" "github.com/git-lfs/git-lfs/progress" - "github.com/git-lfs/git-lfs/transfer" "github.com/rubyist/tracerx" ) @@ -112,8 +111,8 @@ func (b Batch) Swap(i, j int) { b[i], b[j] = b[j], b[i] } // including calling the API, passing the actual transfer request to transfer // adapters, and dealing with progress, errors and retries. type TransferQueue struct { - direction transfer.Direction - adapter transfer.TransferAdapter + direction Direction + adapter TransferAdapter adapterInProgress bool adapterInitMutex sync.Mutex dryRun bool @@ -133,7 +132,7 @@ type TransferQueue struct { // once per unique OID on Add(), and is decremented when that transfer // is marked as completed or failed, but not retried. wait sync.WaitGroup - manifest *transfer.Manifest + manifest *Manifest rc *retryCounter } @@ -160,7 +159,7 @@ func WithBufferDepth(depth int) TransferQueueOption { } // NewTransferQueue builds a TransferQueue, direction and underlying mechanism determined by adapter -func NewTransferQueue(dir transfer.Direction, options ...TransferQueueOption) *TransferQueue { +func NewTransferQueue(dir Direction, options ...TransferQueueOption) *TransferQueue { q := &TransferQueue{ batchSize: defaultBatchSize, bufferDepth: defaultBatchSize, @@ -168,7 +167,7 @@ func NewTransferQueue(dir transfer.Direction, options ...TransferQueueOption) *T errorc: make(chan error), transferables: make(map[string]Transferable), trMutex: &sync.Mutex{}, - manifest: transfer.ConfigureManifest(transfer.NewManifest(), config.Config), + manifest: ConfigureManifest(NewManifest(), config.Config), rc: newRetryCounter(config.Config), } @@ -216,7 +215,7 @@ func (q *TransferQueue) Add(t Transferable) { // b. If the read was a Transferable item, go to step 3. // 3. Append the item to the batch. // 4. Sort the batch by descending object size, make a batch API call, send -// the items to the `*transfer.adapterBase`. +// the items to the `*adapterBase`. // 5. Process the worker results, incrementing and appending retries if // possible. // 6. If the `q.incoming` channel is open, go to step 2. @@ -299,7 +298,7 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch Batch) (Batch, error) q.useAdapter(adapterName) q.startProgress.Do(q.meter.Start) - toTransfer := make([]*transfer.Transfer, 0, len(objs)) + toTransfer := make([]*Transfer, 0, len(objs)) for _, o := range objs { if o.Error != nil { @@ -325,7 +324,7 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch Batch) (Batch, error) t.SetObject(o) q.meter.StartTransfer(t.Name()) - toTransfer = append(toTransfer, transfer.NewTransfer( + toTransfer = append(toTransfer, NewTransfer( t.Name(), t.Object(), t.Path(), )) } else { @@ -367,7 +366,7 @@ func (q *TransferQueue) makeBatch() Batch { return make(Batch, 0, q.batchSize) } // closed. // // addToAdapter returns immediately, and does not block. -func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transferable { +func (q *TransferQueue) addToAdapter(pending []*Transfer) <-chan Transferable { retries := make(chan Transferable, len(pending)) if err := q.ensureAdapterBegun(); err != nil { @@ -385,7 +384,7 @@ func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transf go func() { defer close(retries) - var results <-chan transfer.TransferResult + var results <-chan TransferResult if q.dryRun { results = q.makeDryRunResults(pending) } else { @@ -402,10 +401,10 @@ func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transf // makeDryRunResults returns a channel populated immediately with "successful" // results for all of the given transfers in "ts". -func (q *TransferQueue) makeDryRunResults(ts []*transfer.Transfer) <-chan transfer.TransferResult { - results := make(chan transfer.TransferResult, len(ts)) +func (q *TransferQueue) makeDryRunResults(ts []*Transfer) <-chan TransferResult { + results := make(chan TransferResult, len(ts)) for _, t := range ts { - results <- transfer.TransferResult{t, nil} + results <- TransferResult{t, nil} } close(results) @@ -416,7 +415,7 @@ func (q *TransferQueue) makeDryRunResults(ts []*transfer.Transfer) <-chan transf // handleTransferResult observes the transfer result, sending it on the retries // channel if it was able to be retried. func (q *TransferQueue) handleTransferResult( - res transfer.TransferResult, retries chan<- Transferable, + res TransferResult, retries chan<- Transferable, ) { oid := res.Transfer.Object.Oid @@ -490,7 +489,7 @@ func (q *TransferQueue) Skip(size int64) { } func (q *TransferQueue) transferKind() string { - if q.direction == transfer.Download { + if q.direction == Download { return "download" } else { return "upload" diff --git a/transfer/transfer_test.go b/tq/transfer_test.go similarity index 99% rename from transfer/transfer_test.go rename to tq/transfer_test.go index 5cd86bbb..f26c55c2 100644 --- a/transfer/transfer_test.go +++ b/tq/transfer_test.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "testing" diff --git a/transfer/tus_upload.go b/tq/tus_upload.go similarity index 99% rename from transfer/tus_upload.go rename to tq/tus_upload.go index f3a93a7a..027a85b4 100644 --- a/transfer/tus_upload.go +++ b/tq/tus_upload.go @@ -1,4 +1,4 @@ -package transfer +package tq import ( "fmt"