Skip to content

Commit

Permalink
stray logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Jul 23, 2022
1 parent e22bf13 commit ccd2c8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (c *Client) startWorkers(ctx context.Context, req <-chan FileRequest) *sync
for i := 0; i < c.workers; i++ {
wg.Add(1)
go func(workerNum int) {
c.worker(ctx, fltSeen(req))
c.worker(ctx, c.fltSeen(req))
wg.Done()
c.l().Debugf("download worker %d terminated", workerNum)
}(i)
Expand Down
8 changes: 2 additions & 6 deletions downloader/filters.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package downloader

import (
"log"
)

// fltSeen filters the files from filesC to ensure that no duplicates
// are downloaded.
func fltSeen(filesC <-chan FileRequest) <-chan FileRequest {
func (c *Client) fltSeen(filesC <-chan FileRequest) <-chan FileRequest {
dlQ := make(chan FileRequest)
go func() {
// closing stop will lead to all worker goroutines to terminate.
Expand All @@ -19,7 +15,7 @@ func fltSeen(filesC <-chan FileRequest) <-chan FileRequest {
for f := range filesC {
id := f.File.ID + f.Directory
if _, ok := seen[id]; ok {
log.Printf("already seen %s, skipping", Filename(f.File))
c.l().Debugf("already seen %q, skipping", Filename(f.File))
continue
}
seen[id] = true
Expand Down
8 changes: 5 additions & 3 deletions downloader/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func Test_fltSeen(t *testing.T) {
filesC <- f
}
}()
dlqC := fltSeen(filesC)

c := Client{}
dlqC := c.fltSeen(filesC)

var got []FileRequest
for f := range dlqC {
Expand All @@ -58,8 +60,8 @@ func BenchmarkFltSeen(b *testing.B) {
inputC <- req
}
}()

outputC := fltSeen(inputC)
c := Client{}
outputC := c.fltSeen(inputC)

for n := 0; n < b.N; n++ {
for out := range outputC {
Expand Down

0 comments on commit ccd2c8a

Please sign in to comment.