improve session storage file for ghttp.Server
@@ -41,13 +41,6 @@ var (
DefaultStorageFileLoopInterval = 10 * time.Second
)
-func init() {
- tmpPath := "/tmp"
- if gfile.Exists(tmpPath) && gfile.IsWritable(tmpPath) {
- DefaultStorageFilePath = gfile.Join(tmpPath, "gsessions")
- }
-}
-
// NewStorageFile creates and returns a file storage object for session.
func NewStorageFile(path ...string) *StorageFile {
storagePath := DefaultStorageFilePath
@@ -206,7 +199,9 @@ func (s *StorageFile) SetSession(id string, data *gmap.StrAnyMap, ttl time.Durat
return err
}
}
- file, err := gfile.OpenWithFlag(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
+ file, err := gfile.OpenWithFlagPerm(
+ path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm,
+ )
if err != nil {
return err
}
