mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
fix(commands): explicitly close files (#3031)
This fixes an issue that could potentially cause problems with open files due to a deferred file close in a for loop.
This commit is contained in:
parent
f65643caff
commit
17eef2c679
|
@ -341,15 +341,20 @@ func storageTOTPExportRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
fmt.Println(c.URI())
|
||||
case storageExportFormatPNG:
|
||||
file, _ := os.Create(filepath.Join(dir, fmt.Sprintf("%s.png", c.Username)))
|
||||
defer file.Close()
|
||||
|
||||
if img, err = c.Image(256, 256); err != nil {
|
||||
_ = file.Close()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if err = png.Encode(file, img); err != nil {
|
||||
_ = file.Close()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
_ = file.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user