From 79e2d308491bae12872715910bd5f0e2e041f215 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 11 Sep 2019 23:26:38 +0800 Subject: [PATCH] improve gsession for file storing --- os/gsession/gsession_storage_file.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/os/gsession/gsession_storage_file.go b/os/gsession/gsession_storage_file.go index 7e37ad740..137094802 100644 --- a/os/gsession/gsession_storage_file.go +++ b/os/gsession/gsession_storage_file.go @@ -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,