summaryrefslogtreecommitdiff
path: root/store.go
diff options
context:
space:
mode:
authormoraes <rodrigo.moraes@gmail.com>2012-10-04 01:38:59 +0400
committermoraes <rodrigo.moraes@gmail.com>2012-10-04 01:38:59 +0400
commitc044c93603af0d545821becf4fae68ea969eb074 (patch)
tree8b62e2dc0a226a01bc3788573e9fdb6e37e6222d /store.go
parent918ff72419db9e2713ec29a67d58b186c564b6a0 (diff)
Truncate session files when writing, otherwise we might not be able to parse them later on. Patch from Michael Stapelberg (thanks!). Closes #1
Diffstat (limited to 'store.go')
-rw-r--r--store.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/store.go b/store.go
index 7f0a2cb..8d00cb3 100644
--- a/store.go
+++ b/store.go
@@ -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