fileexporter: Close opened fd
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
961542283d
commit
ac5982f905
3 changed files with 37 additions and 13 deletions
|
@ -14,7 +14,7 @@ import (
|
|||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
var OutputFormats = map[string]func(...string) (func(string) (io.WriteCloser, error), error){}
|
||||
var OutputFormats = map[string]func(...string) (func(string) (io.WriteCloser, error), io.Closer, error){}
|
||||
|
||||
func exportThemeFiles(tdir string) (errs error) {
|
||||
theme, exceptions, err := sync.BuildTheme(sync.GlobalImporter, tdir)
|
||||
|
@ -129,6 +129,13 @@ func main() {
|
|||
|
||||
log.Println("Using", sync.GlobalImporter.Kind())
|
||||
|
||||
hasError := doExport()
|
||||
if hasError {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func doExport() bool {
|
||||
// Configure destination
|
||||
if flag.NArg() < 1 {
|
||||
var formats []string
|
||||
|
@ -147,7 +154,10 @@ func main() {
|
|||
|
||||
log.Fatal("Please define wanted output format between [" + strings.Join(formats, " ") + "]")
|
||||
} else {
|
||||
fw, err := outputFormat(flag.Args()[1:]...)
|
||||
fw, closer, err := outputFormat(flag.Args()[1:]...)
|
||||
if closer != nil {
|
||||
defer closer.Close()
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
} else if fw != nil {
|
||||
|
@ -170,7 +180,5 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
if hasError {
|
||||
os.Exit(1)
|
||||
}
|
||||
return hasError
|
||||
}
|
||||
|
|
Reference in a new issue