From 146fca184119daae9dd6f7d21ea9cf2b75ddbf7d Mon Sep 17 00:00:00 2001 From: Hank Shen Date: Wed, 19 May 2021 12:57:42 +0800 Subject: update --- store.go | 15 +++++---------- 1 file 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 -- cgit v1.2.3