Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion errors/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ var (
SessionDriverExtensionFailed = New("session failed to extend session [%s] driver [%v]")
SessionDriverIsNotSet = New("session driver is not set")
SessionDriverNotSupported = New("session driver [%s] not supported")
SessionNotFound = New("session [%s] not found")

UnknownFileExtension = New("unknown file extension")

Expand Down
3 changes: 1 addition & 2 deletions session/driver/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"
"sync"

"github.com/goravel/framework/errors"
"github.com/goravel/framework/support/carbon"
"github.com/goravel/framework/support/file"
)
Expand Down Expand Up @@ -80,7 +79,7 @@ func (f *File) Read(id string) (string, error) {
}
}

return "", errors.SessionNotFound.Args(id)
return "", nil
Copy link
Member

@devhaozi devhaozi Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Does error errors.SessionNotFound need to be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, we can remove it.

}

func (f *File) Write(id string, data string) error {
Expand Down
6 changes: 3 additions & 3 deletions session/driver/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (f *FileTestSuite) TestDestroy() {
f.Nil(driver.Destroy("foo"))

value, err = driver.Read("foo")
f.NotNil(err)
f.Nil(err)
f.Equal("", value)
}

Expand All @@ -58,7 +58,7 @@ func (f *FileTestSuite) TestGc() {
f.Nil(driver.Gc(300))

value, err = driver.Read("foo")
f.NotNil(err)
f.Nil(err)
f.Equal("", value)
carbon.UnsetTestNow()

Expand Down Expand Up @@ -88,7 +88,7 @@ func (f *FileTestSuite) TestRead() {

carbon.SetTestNow(carbon.Now(carbon.UTC).AddMinutes(f.getMinutes()).AddSecond())
value, err = driver.Read("foo")
f.NotNil(err)
f.Nil(err)
f.Equal("", value)
carbon.UnsetTestNow()
}
Expand Down
9 changes: 6 additions & 3 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,13 @@ func (s *Session) readFromHandler() map[string]any {
return nil
}
var data map[string]any
if err := s.json.Unmarshal([]byte(value), &data); err != nil {
color.Errorln(err)
return nil
if value != "" {
if err := s.json.Unmarshal([]byte(value), &data); err != nil {
color.Errorln(err)
return nil
}
}

return data
}

Expand Down
Loading