Skip to content

Commit e683fba

Browse files
committed
Defer file close
1 parent f2079e4 commit e683fba

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

command/ota/generate.go

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func Generate(binFile string, outFile string, fqbn string) error {
5555
if err != nil {
5656
return err
5757
}
58+
defer out.Close()
5859

5960
enc := inota.NewEncoder(out, arduinoVendorID, productID)
6061
err = enc.Encode(data)

command/ota/massupload.go

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func run(uploader otaUploader, ids []string, otaFile string, expiration int) []R
171171
results = append(results, r)
172172
continue
173173
}
174+
defer file.Close()
174175
jobs <- job{id: id, file: file}
175176
}
176177
close(jobs)

command/ota/upload.go

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func Upload(params *UploadParams, cred *config.Credentials) error {
7171
if err != nil {
7272
return fmt.Errorf("%s: %w", "cannot open ota file", err)
7373
}
74+
defer file.Close()
7475

7576
expiration := otaExpirationMins
7677
if params.Deferred {

0 commit comments

Comments
 (0)