improve gsession for file storing

This commit is contained in:
John
2019-09-11 23:26:38 +08:00
parent e8a9c7ac72
commit 79e2d30849

View File

@ -50,14 +50,17 @@ func NewStorageFile(ttl time.Duration, path ...string) *StorageFile {
if len(path) > 0 && path[0] != "" {
storagePath, _ = gfile.Search(path[0])
if storagePath == "" {
if err := gfile.Mkdir(storagePath); err != nil {
glog.Panicf("mkdir '%s' failed: %v", path[0], err)
}
glog.Panicf("'%s' does not exist", path[0])
}
if !gfile.IsWritable(storagePath) {
glog.Panicf("'%s' is not writable", path[0])
}
}
if storagePath != "" {
if err := gfile.Mkdir(storagePath); err != nil {
glog.Panicf("mkdir '%s' failed: %v", path[0], err)
}
}
s := &StorageFile{
ttl: ttl,
path: storagePath,