improve gsession for file storing
@@ -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,
