From aec0cc08d98d7ddaccefbf9ceb110f448144ddac Mon Sep 17 00:00:00 2001 From: Cheney Date: Thu, 8 Oct 2015 18:14:59 +0800 Subject: [PATCH] fix history rewrite fd close --- history.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history.go b/history.go index 0dd5f39..6f7e77d 100644 --- a/history.go +++ b/history.go @@ -80,7 +80,6 @@ func (o *opHistory) HistoryRewrite() { if err != nil { return } - defer fd.Close() buf := bufio.NewWriter(fd) for elem := o.history.Front(); elem != nil; elem = elem.Next() { @@ -90,6 +89,7 @@ func (o *opHistory) HistoryRewrite() { // replace history file if err = os.Rename(tmpFile, o.cfg.HistoryFile); err != nil { + fd.Close() return }