Skip to content

Commit 632ef3d

Browse files
committed
Enhance Header line writing/skipping logic
1 parent bd2fb52 commit 632ef3d

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

downloader/downloader.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,8 @@ func Get(username string, password string, crawl uint64, mode string,
298298

299299
func (d *Downloader) downloadTarget() error {
300300

301-
for {
301+
for !d.isDone() {
302302
var processedLines int64
303-
304-
if d.isDone() {
305-
// exit
306-
return nil
307-
}
308-
309303
debugf("Calling next chunk")
310304
var chunk []byte
311305
var statusCode int
@@ -399,9 +393,9 @@ func (d *Downloader) downloadTarget() error {
399393
debugf("chunk bytes len: %v", len(chunk))
400394

401395
// write the header of the tsv only if it's the first/only target
402-
if d.TargetsFileNextID == 0 {
396+
if d.CurrentTarget.DoneElements == 0 {
397+
scanner.Scan()
403398
if d.DoneElements == 0 {
404-
scanner.Scan()
405399
outputWriter.Write(append(scanner.Bytes(), []byte("\n")...))
406400
}
407401
}
@@ -439,6 +433,7 @@ func (d *Downloader) downloadTarget() error {
439433
}
440434

441435
}
436+
return nil
442437
}
443438

444439
// Run runs the program

0 commit comments

Comments
 (0)