worker: handle error in defer

There's not much to do when removing the temporary directory fails.
Print a message so that people have the chance to notice.
This commit is contained in:
Lars Karlitski 2020-05-26 15:47:56 +02:00
parent a1cf3984dc
commit b065d8c304

View file

@ -68,8 +68,12 @@ func RunJob(job *worker.Job, uploadFunc func(uuid.UUID, string, io.Reader) error
if err != nil {
return nil, fmt.Errorf("error setting up osbuild output directory: %v", err)
}
// FIXME: how to handle errors in defer?
defer os.RemoveAll(tmpOutput)
defer func() {
err := os.RemoveAll(tmpOutput)
if err != nil {
log.Printf("Error removing temporary directory %s for job %s: %v", tmpOutput, job.Id, err)
}
}()
result, err := RunOSBuild(job.Manifest, tmpOutput, os.Stderr)
if err != nil {