Browse Source

[autofile] close file before renaming it

this might fix our windows bug https://github.com/tendermint/tendermint/issues/444

0980f8e197
pull/1842/head
Anton Kaliaev 8 years ago
parent
commit
74a7f8c92b
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      autofile/group.go

+ 7
- 5
autofile/group.go View File

@ -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
}


Loading…
Cancel
Save