Skip to content

Commit

Permalink
Truncate session files when writing, otherwise we might not be able t…
Browse files Browse the repository at this point in the history
…o parse them later on. Patch from Michael Stapelberg (thanks!). Closes #1
  • Loading branch information
moraes committed Oct 3, 2012
1 parent 918ff72 commit c044c93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions store.go
Expand Up @@ -195,9 +195,9 @@ func (s *FilesystemStore) save(session *Session) error {
filename := s.path + "session_" + session.ID
fileMutex.Lock()
defer fileMutex.Unlock()
fp, err2 := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err2 != nil {
return err2
fp, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
if _, err = fp.Write([]byte(encoded)); err != nil {
return err
Expand Down

0 comments on commit c044c93

Please sign in to comment.