jobimpl-osbuild: split temp dir cleanup into its separate defer
It doesn't make sense to have them together. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
f2f1c8d0f0
commit
19e45b528f
1 changed files with 6 additions and 7 deletions
|
|
@ -278,8 +278,6 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
osbuildJobResult.HostOS = hostOS
|
||||
|
||||
var outputDirectory string
|
||||
|
||||
// In all cases it is necessary to report result back to osbuild-composer worker API.
|
||||
defer func() {
|
||||
validateResult(osbuildJobResult, job.Id().String())
|
||||
|
|
@ -288,18 +286,19 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if err != nil {
|
||||
logWithId.Errorf("Error reporting job result: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
outputDirectory, err := os.MkdirTemp(impl.Output, job.Id().String()+"-*")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating temporary output directory: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
err = os.RemoveAll(outputDirectory)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error removing temporary output directory (%s): %v", outputDirectory, err)
|
||||
}
|
||||
}()
|
||||
|
||||
outputDirectory, err = os.MkdirTemp(impl.Output, job.Id().String()+"-*")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating temporary output directory: %v", err)
|
||||
}
|
||||
|
||||
// Read the job specification
|
||||
var jobArgs worker.OSBuildJob
|
||||
err = job.Args(&jobArgs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue