Just some style corrections

This commit is contained in:
bytedream 2022-03-21 14:30:04 +01:00
parent 98f5da3bf3
commit 588d402c63

View file

@ -89,7 +89,7 @@ func (d Downloader) download(format *Format) error {
} }
if _, err := os.Stat(d.TempDir); os.IsNotExist(err) { if _, err := os.Stat(d.TempDir); os.IsNotExist(err) {
if err := os.Mkdir(d.TempDir, 0700); err != nil { if err = os.Mkdir(d.TempDir, 0700); err != nil {
return err return err
} }
} }
@ -267,12 +267,14 @@ func (d Downloader) downloadSegments(format *Format) ([]string, error) {
break break
} }
if k == 2 { if k == 2 {
file.Close()
cancel() cancel()
return return
} }
select { select {
case <-d.Context.Done(): case <-d.Context.Done():
case <-ctx.Done(): case <-ctx.Done():
file.Close()
return return
case <-time.After(5 * time.Duration(k) * time.Second): case <-time.After(5 * time.Duration(k) * time.Second):
// sleep if an error occurs. very useful because sometimes the connection times out // sleep if an error occurs. very useful because sometimes the connection times out