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:
parent
a1cf3984dc
commit
b065d8c304
1 changed files with 6 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue