Skip to content

Commit 891db97

Browse files
committed
tq,transfer: move pkg "transfer" to "tq"
1 parent c5ce4b7 commit 891db97

16 files changed

+42
-45
lines changed

commands/commands.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/git-lfs/git-lfs/lfs"
2020
"github.com/git-lfs/git-lfs/progress"
2121
"github.com/git-lfs/git-lfs/tools"
22-
"github.com/git-lfs/git-lfs/transfer"
22+
"github.com/git-lfs/git-lfs/tq"
2323
)
2424

2525
// Populate man pages
@@ -41,10 +41,10 @@ var (
4141
excludeArg string
4242
)
4343

44-
// TransferManifest builds a transfer.Manifest from the commands package global
44+
// TransferManifest builds a tq.Manifest from the commands package global
4545
// cfg var.
46-
func TransferManifest() *transfer.Manifest {
47-
return transfer.ConfigureManifest(transfer.NewManifest(), cfg)
46+
func TransferManifest() *tq.Manifest {
47+
return tq.ConfigureManifest(tq.NewManifest(), cfg)
4848
}
4949

5050
// Error prints a formatted message to Stderr. It also gets printed to the

lfs/download_queue.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package lfs
33
import (
44
"github.com/git-lfs/git-lfs/api"
55
"github.com/git-lfs/git-lfs/tq"
6-
"github.com/git-lfs/git-lfs/transfer"
76
)
87

98
type Downloadable struct {
@@ -42,10 +41,10 @@ func NewDownloadable(p *WrappedPointer) *Downloadable {
4241

4342
// NewDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
4443
func NewDownloadCheckQueue(options ...tq.TransferQueueOption) *tq.TransferQueue {
45-
return tq.NewTransferQueue(transfer.Download, options...)
44+
return tq.NewTransferQueue(tq.Download, options...)
4645
}
4746

4847
// NewDownloadQueue builds a DownloadQueue, allowing concurrent downloads.
4948
func NewDownloadQueue(options ...tq.TransferQueueOption) *tq.TransferQueue {
50-
return tq.NewTransferQueue(transfer.Download, options...)
49+
return tq.NewTransferQueue(tq.Download, options...)
5150
}

lfs/lfs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/git-lfs/git-lfs/config"
1313
"github.com/git-lfs/git-lfs/localstorage"
1414
"github.com/git-lfs/git-lfs/tools"
15-
"github.com/git-lfs/git-lfs/transfer"
15+
"github.com/git-lfs/git-lfs/tq"
1616
"github.com/rubyist/tracerx"
1717
)
1818

@@ -63,7 +63,7 @@ func ObjectExistsOfSize(oid string, size int64) bool {
6363
return tools.FileExistsOfSize(path, size)
6464
}
6565

66-
func Environ(cfg *config.Configuration, manifest *transfer.Manifest) []string {
66+
func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string {
6767
osEnviron := os.Environ()
6868
env := make([]string, 0, len(osEnviron)+7)
6969

lfs/pointer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/git-lfs/git-lfs/errors"
1515
"github.com/git-lfs/git-lfs/progress"
16-
"github.com/git-lfs/git-lfs/transfer"
16+
"github.com/git-lfs/git-lfs/tq"
1717
)
1818

1919
var (
@@ -60,7 +60,7 @@ func NewPointerExtension(name string, priority int, oid string) *PointerExtensio
6060
return &PointerExtension{name, priority, oid, oidType}
6161
}
6262

63-
func (p *Pointer) Smudge(writer io.Writer, workingfile string, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error {
63+
func (p *Pointer) Smudge(writer io.Writer, workingfile string, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error {
6464
return PointerSmudge(writer, p, workingfile, download, manifest, cb)
6565
}
6666

lfs/pointer_smudge.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/cheggaaa/pb"
1010
"github.com/git-lfs/git-lfs/tools"
11-
"github.com/git-lfs/git-lfs/transfer"
11+
"github.com/git-lfs/git-lfs/tq"
1212

1313
"github.com/git-lfs/git-lfs/api"
1414
"github.com/git-lfs/git-lfs/config"
@@ -17,7 +17,7 @@ import (
1717
"github.com/rubyist/tracerx"
1818
)
1919

20-
func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error {
20+
func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error {
2121
os.MkdirAll(filepath.Dir(filename), 0755)
2222
file, err := os.Create(filename)
2323
if err != nil {
@@ -37,7 +37,7 @@ func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest
3737
return nil
3838
}
3939

40-
func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, manifest *transfer.Manifest, cb progress.CopyCallback) error {
40+
func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, manifest *tq.Manifest, cb progress.CopyCallback) error {
4141
mediafile, err := LocalMediaPath(ptr.Oid)
4242
if err != nil {
4343
return err
@@ -72,7 +72,7 @@ func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download
7272
return nil
7373
}
7474

75-
func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string, manifest *transfer.Manifest, cb progress.CopyCallback) error {
75+
func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string, manifest *tq.Manifest, cb progress.CopyCallback) error {
7676
fmt.Fprintf(os.Stderr, "Downloading %s (%s)\n", workingfile, pb.FormatBytes(ptr.Size))
7777

7878
xfers := manifest.GetDownloadAdapterNames()
@@ -86,19 +86,19 @@ func downloadFile(writer io.Writer, ptr *Pointer, workingfile, mediafile string,
8686
}
8787

8888
adapter := manifest.NewDownloadAdapter(adapterName)
89-
var tcb transfer.TransferProgressCallback
89+
var tcb tq.TransferProgressCallback
9090
if cb != nil {
9191
tcb = func(name string, totalSize, readSoFar int64, readSinceLast int) error {
9292
return cb(totalSize, readSoFar, readSinceLast)
9393
}
9494
}
9595
// Single download
96-
adapterResultChan := make(chan transfer.TransferResult, 1)
96+
adapterResultChan := make(chan tq.TransferResult, 1)
9797
err = adapter.Begin(1, tcb, adapterResultChan)
9898
if err != nil {
9999
return err
100100
}
101-
adapter.Add(transfer.NewTransfer(filepath.Base(workingfile), obj, mediafile))
101+
adapter.Add(tq.NewTransfer(filepath.Base(workingfile), obj, mediafile))
102102
adapter.End()
103103
res := <-adapterResultChan
104104

lfs/upload_queue.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/git-lfs/git-lfs/config"
1010
"github.com/git-lfs/git-lfs/errors"
1111
"github.com/git-lfs/git-lfs/tq"
12-
"github.com/git-lfs/git-lfs/transfer"
1312
)
1413

1514
// Uploadable describes a file that can be uploaded.
@@ -69,7 +68,7 @@ func NewUploadable(oid, filename string) (*Uploadable, error) {
6968

7069
// NewUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
7170
func NewUploadQueue(options ...tq.TransferQueueOption) *tq.TransferQueue {
72-
return tq.NewTransferQueue(transfer.Upload, options...)
71+
return tq.NewTransferQueue(tq.Upload, options...)
7372
}
7473

7574
// ensureFile makes sure that the cleanPath exists before pushing it. If it

transfer/adapterbase.go tq/adapterbase.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"fmt"

transfer/basic_download.go tq/basic_download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"fmt"

transfer/basic_upload.go tq/basic_upload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"fmt"

transfer/custom.go tq/custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"bufio"

transfer/custom_test.go tq/custom_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"testing"

transfer/manifest.go tq/manifest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"sync"

transfer/transfer.go tq/transfer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package transfer collects together adapters for uploading and downloading LFS content
22
// NOTE: Subject to change, do not rely on this package from outside git-lfs source
3-
package transfer
3+
package tq
44

55
import "github.com/git-lfs/git-lfs/api"
66

tq/transfer_queue.go

+15-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/git-lfs/git-lfs/config"
99
"github.com/git-lfs/git-lfs/errors"
1010
"github.com/git-lfs/git-lfs/progress"
11-
"github.com/git-lfs/git-lfs/transfer"
1211
"github.com/rubyist/tracerx"
1312
)
1413

@@ -112,8 +111,8 @@ func (b Batch) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
112111
// including calling the API, passing the actual transfer request to transfer
113112
// adapters, and dealing with progress, errors and retries.
114113
type TransferQueue struct {
115-
direction transfer.Direction
116-
adapter transfer.TransferAdapter
114+
direction Direction
115+
adapter TransferAdapter
117116
adapterInProgress bool
118117
adapterInitMutex sync.Mutex
119118
dryRun bool
@@ -133,7 +132,7 @@ type TransferQueue struct {
133132
// once per unique OID on Add(), and is decremented when that transfer
134133
// is marked as completed or failed, but not retried.
135134
wait sync.WaitGroup
136-
manifest *transfer.Manifest
135+
manifest *Manifest
137136
rc *retryCounter
138137
}
139138

@@ -160,15 +159,15 @@ func WithBufferDepth(depth int) TransferQueueOption {
160159
}
161160

162161
// NewTransferQueue builds a TransferQueue, direction and underlying mechanism determined by adapter
163-
func NewTransferQueue(dir transfer.Direction, options ...TransferQueueOption) *TransferQueue {
162+
func NewTransferQueue(dir Direction, options ...TransferQueueOption) *TransferQueue {
164163
q := &TransferQueue{
165164
batchSize: defaultBatchSize,
166165
bufferDepth: defaultBatchSize,
167166
direction: dir,
168167
errorc: make(chan error),
169168
transferables: make(map[string]Transferable),
170169
trMutex: &sync.Mutex{},
171-
manifest: transfer.ConfigureManifest(transfer.NewManifest(), config.Config),
170+
manifest: ConfigureManifest(NewManifest(), config.Config),
172171
rc: newRetryCounter(config.Config),
173172
}
174173

@@ -216,7 +215,7 @@ func (q *TransferQueue) Add(t Transferable) {
216215
// b. If the read was a Transferable item, go to step 3.
217216
// 3. Append the item to the batch.
218217
// 4. Sort the batch by descending object size, make a batch API call, send
219-
// the items to the `*transfer.adapterBase`.
218+
// the items to the `*adapterBase`.
220219
// 5. Process the worker results, incrementing and appending retries if
221220
// possible.
222221
// 6. If the `q.incoming` channel is open, go to step 2.
@@ -299,7 +298,7 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch Batch) (Batch, error)
299298
q.useAdapter(adapterName)
300299
q.startProgress.Do(q.meter.Start)
301300

302-
toTransfer := make([]*transfer.Transfer, 0, len(objs))
301+
toTransfer := make([]*Transfer, 0, len(objs))
303302

304303
for _, o := range objs {
305304
if o.Error != nil {
@@ -325,7 +324,7 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch Batch) (Batch, error)
325324
t.SetObject(o)
326325
q.meter.StartTransfer(t.Name())
327326

328-
toTransfer = append(toTransfer, transfer.NewTransfer(
327+
toTransfer = append(toTransfer, NewTransfer(
329328
t.Name(), t.Object(), t.Path(),
330329
))
331330
} else {
@@ -367,7 +366,7 @@ func (q *TransferQueue) makeBatch() Batch { return make(Batch, 0, q.batchSize) }
367366
// closed.
368367
//
369368
// addToAdapter returns immediately, and does not block.
370-
func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transferable {
369+
func (q *TransferQueue) addToAdapter(pending []*Transfer) <-chan Transferable {
371370
retries := make(chan Transferable, len(pending))
372371

373372
if err := q.ensureAdapterBegun(); err != nil {
@@ -385,7 +384,7 @@ func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transf
385384
go func() {
386385
defer close(retries)
387386

388-
var results <-chan transfer.TransferResult
387+
var results <-chan TransferResult
389388
if q.dryRun {
390389
results = q.makeDryRunResults(pending)
391390
} else {
@@ -402,10 +401,10 @@ func (q *TransferQueue) addToAdapter(pending []*transfer.Transfer) <-chan Transf
402401

403402
// makeDryRunResults returns a channel populated immediately with "successful"
404403
// results for all of the given transfers in "ts".
405-
func (q *TransferQueue) makeDryRunResults(ts []*transfer.Transfer) <-chan transfer.TransferResult {
406-
results := make(chan transfer.TransferResult, len(ts))
404+
func (q *TransferQueue) makeDryRunResults(ts []*Transfer) <-chan TransferResult {
405+
results := make(chan TransferResult, len(ts))
407406
for _, t := range ts {
408-
results <- transfer.TransferResult{t, nil}
407+
results <- TransferResult{t, nil}
409408
}
410409

411410
close(results)
@@ -416,7 +415,7 @@ func (q *TransferQueue) makeDryRunResults(ts []*transfer.Transfer) <-chan transf
416415
// handleTransferResult observes the transfer result, sending it on the retries
417416
// channel if it was able to be retried.
418417
func (q *TransferQueue) handleTransferResult(
419-
res transfer.TransferResult, retries chan<- Transferable,
418+
res TransferResult, retries chan<- Transferable,
420419
) {
421420
oid := res.Transfer.Object.Oid
422421

@@ -490,7 +489,7 @@ func (q *TransferQueue) Skip(size int64) {
490489
}
491490

492491
func (q *TransferQueue) transferKind() string {
493-
if q.direction == transfer.Download {
492+
if q.direction == Download {
494493
return "download"
495494
} else {
496495
return "upload"

transfer/transfer_test.go tq/transfer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"testing"

transfer/tus_upload.go tq/tus_upload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package transfer
1+
package tq
22

33
import (
44
"fmt"

0 commit comments

Comments
 (0)