We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diff --git a/wal/global_state.go b/wal/global_state.go index 92e3666..9b161ee 100644 --- a/wal/global_state.go +++ b/wal/global_state.go @@ -44,8 +44,10 @@ func newGlobalState(path string) (*GlobalState, error) { return nil, err } if err := state.read(f); err != nil { + f.Close() return nil, err } + f.Close() state.path = path return state, nil } @@ -57,14 +59,17 @@ func (self *GlobalState) writeToFile() error { } if _, err := newFile.Seek(0, os.SEEK_SET); err != nil { + newFile.Close() return err } if err := self.write(newFile); err != nil { + newFile.Close() return err } if err := newFile.Sync(); err != nil { + newFile.Close() return err } @@ -72,7 +77,9 @@ func (self *GlobalState) writeToFile() error { return err } - os.Remove(self.path) + if err := os.Remove(self.path); nil != err && !os.IsNotExist(err) { + return err + } return os.Rename(self.path+".new", self.path) }
The text was updated successfully, but these errors were encountered:
a9d73f5
It isn't fix it.
@@ -32,6 +32,10 @@ type GlobalState struct { func newGlobalState(path string) (*GlobalState, error) { f, err := os.Open(path) + if err != nil { + defer f.Close() + } + state := &GlobalState{ ServerLastRequestNumber: map[uint32]uint32{}, ShardLastSequenceNumber: map[uint32]uint64{},
" if err != nil {" is error code, " if err == nil {" is ok.
pull request is "ensure close file before rename bookmark file. #840"
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: