summaryrefslogtreecommitdiffstats
path: root/vendor/gitea.com/macaron/session/file.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-09-02 22:10:35 +0100
committerGitHub <noreply@github.com>2020-09-02 17:10:35 -0400
commit5fd9f72104aab3136133ec5b058bd67cb39cf314 (patch)
treeffdf73c3305fdcb9e3ed4430dc96910762cb0e78 /vendor/gitea.com/macaron/session/file.go
parented81a95a84bf4da55c49b76a2708d0cc94be3ad6 (diff)
downloadgitea-5fd9f72104aab3136133ec5b058bd67cb39cf314.tar.gz
gitea-5fd9f72104aab3136133ec5b058bd67cb39cf314.zip
When reading expired sessions - expire them (#12686)
* When reading expired sessions - expire them Update to latest macaron/session following merge of https://gitea.com/macaron/session/pulls/11 Also remove old memory provider as 11 updates the memory provider to make it unnecessary. Signed-off-by: Andrew Thornton <art27@cantab.net> * and macaron/session/pulls/12 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'vendor/gitea.com/macaron/session/file.go')
-rw-r--r--vendor/gitea.com/macaron/session/file.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/gitea.com/macaron/session/file.go b/vendor/gitea.com/macaron/session/file.go
index 3e575564ee..ce915344fb 100644
--- a/vendor/gitea.com/macaron/session/file.go
+++ b/vendor/gitea.com/macaron/session/file.go
@@ -133,7 +133,15 @@ func (p *FileProvider) Read(sid string) (_ RawStore, err error) {
defer p.lock.RUnlock()
var f *os.File
+ ok := false
if com.IsFile(filename) {
+ modTime, err := com.FileMTime(filename)
+ if err != nil {
+ return nil, err
+ }
+ ok = (modTime + p.maxlifetime) >= time.Now().Unix()
+ }
+ if ok {
f, err = os.OpenFile(filename, os.O_RDONLY, 0600)
} else {
f, err = os.Create(filename)