Appease the linter

This commit is contained in:
2023-03-15 04:45:10 +10:30
parent c8f10e01c7
commit 4909f63c93
3 changed files with 71 additions and 22 deletions

View File

@@ -250,7 +250,10 @@ func (dl *Download) Stop() {
dl.Lock.Lock()
defer dl.Lock.Unlock()
dl.Log = append(dl.Log, "aborted by user")
dl.Process.Kill()
err := dl.Process.Kill()
if err != nil {
log.Printf("could not send kill to process: %s", err)
}
}
// domain returns a domain for this Download. Download should be locked.
@@ -335,19 +338,30 @@ func (dl *Download) Begin() {
}()
wg.Wait()
cmd.Wait()
err = cmd.Wait()
dl.Lock.Lock()
log.Printf("Process finished for id: %d (%v)", dl.Id, cmd)
if err != nil {
log.Printf("process failed for id: %d: %s", dl.Id, err)
dl.State = STATE_COMPLETE
dl.Finished = true
dl.FinishedTS = time.Now()
dl.ExitCode = cmd.ProcessState.ExitCode()
if dl.ExitCode != 0 {
dl.State = STATE_FAILED
dl.Finished = true
dl.FinishedTS = time.Now()
dl.ExitCode = cmd.ProcessState.ExitCode()
} else {
log.Printf("process finished for id: %d (%v)", dl.Id, cmd)
dl.State = STATE_COMPLETE
dl.Finished = true
dl.FinishedTS = time.Now()
dl.ExitCode = cmd.ProcessState.ExitCode()
if dl.ExitCode != 0 {
dl.State = STATE_FAILED
}
}
dl.Lock.Unlock()