Skip to content

Commit bd2fb52

Browse files
committed
Rename downloader to d in methods with Downloader receiver
1 parent b794012 commit bd2fb52

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

downloader/downloader.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (d *Downloader) downloadTarget() error {
301301
for {
302302
var processedLines int64
303303

304-
if downloader.isDone() {
304+
if d.isDone() {
305305
// exit
306306
return nil
307307
}
@@ -312,7 +312,7 @@ func (d *Downloader) downloadTarget() error {
312312
var skip uint64
313313
err := retry(5, 10, func() error {
314314
var err error
315-
chunk, statusCode, skip, err = downloader.nextChunk()
315+
chunk, statusCode, skip, err = d.nextChunk()
316316
return err
317317
})
318318

@@ -400,7 +400,7 @@ func (d *Downloader) downloadTarget() error {
400400

401401
// write the header of the tsv only if it's the first/only target
402402
if d.TargetsFileNextID == 0 {
403-
if downloader.DoneElements == 0 {
403+
if d.DoneElements == 0 {
404404
scanner.Scan()
405405
outputWriter.Write(append(scanner.Bytes(), []byte("\n")...))
406406
}
@@ -418,8 +418,8 @@ func (d *Downloader) downloadTarget() error {
418418
outputWriter.Write(append(scanner.Bytes(), []byte("\n")...))
419419

420420
// update the in-memory resumer
421-
downloader.CurrentTarget.DoneElements++
422-
downloader.DoneElements++
421+
d.CurrentTarget.DoneElements++
422+
d.DoneElements++
423423

424424
// update the count of lines processed for this chunk
425425
processedLines++
@@ -429,8 +429,8 @@ func (d *Downloader) downloadTarget() error {
429429
outputWriter.Flush()
430430

431431
// save to file the resumer data (to be able to resume later)
432-
downloader.PersistConfig()
433-
debugf("downloader.DoneElements = %v", downloader.CurrentTarget.DoneElements)
432+
d.PersistConfig()
433+
debugf("downloader.DoneElements = %v", d.CurrentTarget.DoneElements)
434434

435435
// scanner error
436436
if err := scanner.Err(); err != nil {
@@ -506,15 +506,15 @@ func (d *Downloader) nextChunkNumber() (nextChunkNumber, skipNRows uint64) {
506506
// if the remaining elements are less than the page size,
507507
// request only the remaining elements without having
508508
// to discard anything.
509-
remainingElements := downloader.CurrentTarget.TotalElements - downloader.CurrentTarget.DoneElements
509+
remainingElements := d.CurrentTarget.TotalElements - d.CurrentTarget.DoneElements
510510
if remainingElements < client.ChunkSize && remainingElements > 0 {
511511
// r.chunkSize = remainingElements
512512
client.SetChunkSize(remainingElements)
513513
}
514514

515515
// if no elements has been downloaded,
516516
// request the first chunk without skipping rows
517-
if downloader.CurrentTarget.DoneElements == 0 {
517+
if d.CurrentTarget.DoneElements == 0 {
518518
nextChunkNumber = 0
519519
skipNRows = 0
520520
client.SetNextChunkNumber(0)
@@ -527,12 +527,12 @@ func (d *Downloader) nextChunkNumber() (nextChunkNumber, skipNRows uint64) {
527527
client.SetChunkSize(1)
528528
}
529529

530-
skipNRows = downloader.CurrentTarget.DoneElements % client.ChunkSize
531-
nextChunkNumberFloat, _ := math.Modf(float64(downloader.CurrentTarget.DoneElements) / float64(client.ChunkSize))
530+
skipNRows = d.CurrentTarget.DoneElements % client.ChunkSize
531+
nextChunkNumberFloat, _ := math.Modf(float64(d.CurrentTarget.DoneElements) / float64(client.ChunkSize))
532532

533533
// just in case nextChunkNumber() gets called when all elements are
534534
// already downloaded, download chunk and discard all elements
535-
if downloader.CurrentTarget.DoneElements == downloader.CurrentTarget.TotalElements {
535+
if d.CurrentTarget.DoneElements == d.CurrentTarget.TotalElements {
536536
skipNRows = 1
537537
// r.chunkSize = 1
538538
client.SetChunkSize(1)
@@ -548,7 +548,7 @@ func (d *Downloader) nextChunk() ([]byte, int, uint64, error) {
548548

549549
_, skipNRows := d.nextChunkNumber()
550550

551-
if downloader.CurrentTarget.DoneElements > 0 {
551+
if d.CurrentTarget.DoneElements > 0 {
552552
skipNRows++
553553
}
554554

0 commit comments

Comments
 (0)