From 74a7f8c92b66abe75fc04c7b0a17ba52e101caef Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Sat, 6 May 2017 22:48:08 +0400 Subject: [PATCH] [autofile] close file before renaming it this might fix our windows bug https://github.com/tendermint/tendermint/issues/444 https://github.com/Netflix-Skunkworks/go-jira/commit/0980f8e1972a942e505b1939935adf0f7a71f387 --- autofile/group.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/autofile/group.go b/autofile/group.go index 0f829309a..39f274e04 100644 --- a/autofile/group.go +++ b/autofile/group.go @@ -224,15 +224,17 @@ func (g *Group) RotateFile() { g.mtx.Lock() defer g.mtx.Unlock() - dstPath := filePathForIndex(g.Head.Path, g.maxIndex, g.maxIndex+1) - err := os.Rename(g.Head.Path, dstPath) - if err != nil { + headPath := g.Head.Path + + if err := g.Head.closeFile(); err != nil { panic(err) } - err = g.Head.closeFile() - if err != nil { + + indexPath := filePathForIndex(headPath, g.maxIndex, g.maxIndex+1) + if err := os.Rename(headPath, indexPath); err != nil { panic(err) } + g.maxIndex += 1 }