mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 05:00:19 +00:00
fix #235
This commit is contained in:
@ -2,6 +2,7 @@ package session
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -131,6 +132,18 @@ func (fp *FileProvider) SessionGC() {
|
||||
filepath.Walk(fp.savePath, gcpath)
|
||||
}
|
||||
|
||||
func (fp *FileProvider) SessionAll() int {
|
||||
a := &activeSession{}
|
||||
err := filepath.Walk(fp.savePath, func(path string, f os.FileInfo, err error) error {
|
||||
return a.visit(path, f, err)
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("filepath.Walk() returned %v\n", err)
|
||||
return 0
|
||||
}
|
||||
return a.total
|
||||
}
|
||||
|
||||
func (fp *FileProvider) SessionRegenerate(oldsid, sid string) (SessionStore, error) {
|
||||
err := os.MkdirAll(path.Join(fp.savePath, string(oldsid[0]), string(oldsid[1])), 0777)
|
||||
if err != nil {
|
||||
@ -193,6 +206,21 @@ func gcpath(path string, info os.FileInfo, err error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type activeSession struct {
|
||||
total int
|
||||
}
|
||||
|
||||
func (self *activeSession) visit(paths string, f os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
self.total = self.total + 1
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register("file", filepder)
|
||||
}
|
||||
|
Reference in New Issue
Block a user