Skip to content

Commit

Permalink
refactoring: utilize firstNonNil
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Mar 15, 2024
1 parent 28eb8fc commit 98ddc39
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions part.go
Expand Up @@ -131,12 +131,10 @@ func (p *Part) download(client *http.Client, req *http.Request, timeout, sleep t
}
defer func() {
if e := fpart.Close(); e != nil {
p.dlogger.Printf("Part close error: %s", e.Error())
err = firstNonNil(err, e)
} else if p.Written == 0 {
p.dlogger.Printf("Removing: %q", fpart.Name())
if e = os.Remove(p.FileName); e != nil {
p.dlogger.Printf("Part remove error: %s", e.Error())
}
p.dlogger.Printf("file %q is empty, removing", fpart.Name())
err = firstNonNil(err, os.Remove(fpart.Name()))
}
err = errors.WithMessage(err, p.name)
}()
Expand Down

0 comments on commit 98ddc39

Please sign in to comment.