aboutsummaryrefslogtreecommitdiff
path: root/store.go
diff options
context:
space:
mode:
authorHank Shen <swhbox@foxmail.com>2021-05-19 07:57:42 +0300
committerHank Shen <swhbox@foxmail.com>2021-05-19 07:57:42 +0300
commit146fca184119daae9dd6f7d21ea9cf2b75ddbf7d (patch)
tree443682ed9051053e5d1bf5978205f7cd52ec2641 /store.go
parentccf4afe08439ae1d07ee1f32ad69b6b527f8e782 (diff)
updatev0.1.1
Diffstat (limited to 'store.go')
-rw-r--r--store.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/store.go b/store.go
index 3a008d4..3d3bf02 100644
--- a/store.go
+++ b/store.go
@@ -233,7 +233,7 @@ func (s *FilesystemStore) Reload(ctx echo.Context, session *Session) error {
func (s *FilesystemStore) Save(ctx echo.Context, session *Session) error {
// Delete if max-age is < 0
if ctx.CookieOptions().MaxAge < 0 {
- if err := s.erase(session); err != nil && !os.IsNotExist(err) {
+ if err := s.erase(session); err != nil {
return err
}
SetCookie(ctx, session.Name(), "", -1)
@@ -267,20 +267,15 @@ func (s *FilesystemStore) Remove(sessionID string) error {
defer fileMutex.RUnlock()
err := os.Remove(filename)
+ if err != nil && os.IsNotExist(err) {
+ return nil
+ }
return err
}
// delete session file
func (s *FilesystemStore) erase(session *Session) error {
- if len(session.ID) == 0 {
- return nil
- }
- filename := filepath.Join(s.path, "session_"+session.ID)
- fileMutex.RLock()
- defer fileMutex.RUnlock()
-
- err := os.Remove(filename)
- return err
+ return s.Remove(session.ID)
}
// MaxAge sets the maximum age for the store and the underlying cookie