Skip to content
New issue

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

Improve File System Path Handling #274

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions store.go
Expand Up @@ -257,15 +257,15 @@ func (s *FilesystemStore) save(session *Session) error {
if err != nil {
return err
}
filename := filepath.Join(s.path, "session_"+session.ID)
filename := filepath.Join(s.path, filepath.Base("session_"+session.ID))
AlexVulaj marked this conversation as resolved.
Show resolved Hide resolved
fileMutex.Lock()
defer fileMutex.Unlock()
return os.WriteFile(filename, []byte(encoded), 0600)
}

// load reads a file and decodes its content into session.Values.
func (s *FilesystemStore) load(session *Session) error {
filename := filepath.Join(s.path, "session_"+session.ID)
filename := filepath.Join(s.path, filepath.Base("session_"+session.ID))
fileMutex.RLock()
defer fileMutex.RUnlock()
fdata, err := os.ReadFile(filepath.Clean(filename))
Expand All @@ -281,7 +281,7 @@ func (s *FilesystemStore) load(session *Session) error {

// delete session file
func (s *FilesystemStore) erase(session *Session) error {
filename := filepath.Join(s.path, "session_"+session.ID)
filename := filepath.Join(s.path, filepath.Base("session_"+session.ID))

fileMutex.RLock()
defer fileMutex.RUnlock()
Expand Down