mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-14 23:13:01 -06:00
[bugfix] close files before error return (#3163)
* close files before error return * use defer statements * shuffle around some defers
This commit is contained in:
parent
0f734a2410
commit
e5e996b28a
2 changed files with 9 additions and 9 deletions
|
|
@ -75,12 +75,14 @@ func terminateExif(outpath, inpath string, ext string) error {
|
|||
if err != nil {
|
||||
return gtserror.Newf("error opening input file %s: %w", inpath, err)
|
||||
}
|
||||
defer inFile.Close()
|
||||
|
||||
// Open output file at given path.
|
||||
outFile, err := os.Create(outpath)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error opening output file %s: %w", outpath, err)
|
||||
}
|
||||
defer outFile.Close()
|
||||
|
||||
// Terminate EXIF data from 'inFile' -> 'outFile'.
|
||||
err = terminator.TerminateInto(outFile, inFile, ext)
|
||||
|
|
@ -88,9 +90,5 @@ func terminateExif(outpath, inpath string, ext string) error {
|
|||
return gtserror.Newf("error terminating exif data: %w", err)
|
||||
}
|
||||
|
||||
// Done with files.
|
||||
_ = inFile.Close()
|
||||
_ = outFile.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue