summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-03-25 13:07:02 +0000
committerNick White <git@njw.name>2021-03-25 13:07:02 +0000
commit47576e7f390fa62efde85ed79662b42c5cceff5c (patch)
tree6a424f9c22b2b742ac89d069cd642b3080b813e9
parent22cde75eb77eae3f587fad93cd918e2402c6cf73 (diff)
extracthocrlines: ensure opened files are closed promptly, to forego any too many open files errors
-rw-r--r--cmd/extracthocrlines/main.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmd/extracthocrlines/main.go b/cmd/extracthocrlines/main.go
index 34652ea..c213d9f 100644
--- a/cmd/extracthocrlines/main.go
+++ b/cmd/extracthocrlines/main.go
@@ -40,6 +40,7 @@ func saveline(l line.Detail, dir string) error {
if err != nil {
return fmt.Errorf("Error creating file %s: %v", base+".png", err)
}
+ defer f.Close()
err = l.Img.CopyLineTo(f)
if err != nil {
@@ -50,6 +51,7 @@ func saveline(l line.Detail, dir string) error {
if err != nil {
return fmt.Errorf("Error creating file %s: %v", base+".txt", err)
}
+ defer f.Close()
_, err = io.WriteString(f, l.Text)
if err != nil {