fix: only destroy session if exists

The virtual session doesn't unconditionally call `Read` of the provider,
which means it's possible for a session to not exists (created by the
call to `Read`). To avoid that the call to `Destroy` fails with that the
session does not exists, do also the exists check for `Destroy`.
This commit is contained in:
Gusted 2026-03-19 02:18:52 +01:00
parent 31fff54e17
commit ea9f2a236b
No known key found for this signature in database
GPG key ID: FD821B732837125F

View file

@ -76,8 +76,11 @@ func (o *VirtualSessionProvider) Exist(sid string) bool {
func (o *VirtualSessionProvider) Destroy(sid string) error {
o.lock.Lock()
defer o.lock.Unlock()
if o.provider.Exist(sid) {
return o.provider.Destroy(sid)
}
return nil
}
// Regenerate regenerates a session store from old session ID to new one.
func (o *VirtualSessionProvider) Regenerate(oldsid, sid string) (session.RawStore, error) {