Skip to content

Commit

Permalink
Download no longer needs its own lock
Browse files Browse the repository at this point in the history
  • Loading branch information
suzaku committed Aug 11, 2020
1 parent df11970 commit 9e36aad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
1 change: 0 additions & 1 deletion cmd/got/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func main() {
URL: url,
Dest: *dest,
ProgressFunc: func(i int64, t int64, d *got.Download) {

fmt.Printf(
"\r\r\b Total Size: %s | Chunk Size: %s | Concurrency: %d | Progress: %s ",
humanize.Bytes(uint64(t)),
Expand Down
15 changes: 1 addition & 14 deletions got.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ type (

// Progress...
progress *Progress

// Sync mutex.
mu sync.Mutex
}
)

Expand Down Expand Up @@ -103,9 +100,7 @@ func (d *Download) Init() error {
}

// Init progress.
d.progress = &Progress{
mu: d.mu,
}
d.progress = &Progress{}

// Set default interval.
if d.Interval == 0 {
Expand Down Expand Up @@ -196,7 +191,6 @@ func (d *Download) Init() error {

// Start downloading.
func (d *Download) Start() (err error) {

var (
doneChan chan bool = make(chan bool, 1)
errChan chan error = make(chan error)
Expand Down Expand Up @@ -243,25 +237,18 @@ func (d *Download) Start() (err error) {

// Wait for chunks...
for {

select {

case err := <-errChan:

if err != nil {
return err
}

break

case <-doneChan:

d.StopProgress = true

if d.ProgressFunc != nil {
d.ProgressFunc(d.progress.Size, d.Info.Length, d)
}

return nil
}
}
Expand Down

0 comments on commit 9e36aad

Please sign in to comment.