fix history rewrite fd close

This commit is contained in:
Cheney 2015-10-08 18:14:59 +08:00
parent 9f55547f9b
commit aec0cc08d9
1 changed files with 1 additions and 1 deletions

View File

@ -80,7 +80,6 @@ func (o *opHistory) HistoryRewrite() {
if err != nil { if err != nil {
return return
} }
defer fd.Close()
buf := bufio.NewWriter(fd) buf := bufio.NewWriter(fd)
for elem := o.history.Front(); elem != nil; elem = elem.Next() { for elem := o.history.Front(); elem != nil; elem = elem.Next() {
@ -90,6 +89,7 @@ func (o *opHistory) HistoryRewrite() {
// replace history file // replace history file
if err = os.Rename(tmpFile, o.cfg.HistoryFile); err != nil { if err = os.Rename(tmpFile, o.cfg.HistoryFile); err != nil {
fd.Close()
return return
} }