mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-16 22:10:26 +00:00
config: Use float64 within the autosave processing
This commit is contained in:
parent
832c7deaf8
commit
4170df89eb
3 changed files with 6 additions and 6 deletions
|
|
@ -357,7 +357,7 @@ func main() {
|
|||
}
|
||||
|
||||
if a := config.GetGlobalOption("autosave").(float64); a > 0 {
|
||||
config.SetAutoTime(int(a))
|
||||
config.SetAutoTime(a)
|
||||
config.StartAutoSave()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ func doSetGlobalOptionNative(option string, nativeValue interface{}) error {
|
|||
}
|
||||
} else if option == "autosave" {
|
||||
if nativeValue.(float64) > 0 {
|
||||
config.SetAutoTime(int(nativeValue.(float64)))
|
||||
config.SetAutoTime(nativeValue.(float64))
|
||||
config.StartAutoSave()
|
||||
} else {
|
||||
config.SetAutoTime(0)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
var Autosave chan bool
|
||||
var autotime int
|
||||
var autotime float64
|
||||
|
||||
// lock for autosave
|
||||
var autolock sync.Mutex
|
||||
|
|
@ -15,7 +15,7 @@ func init() {
|
|||
Autosave = make(chan bool)
|
||||
}
|
||||
|
||||
func SetAutoTime(a int) {
|
||||
func SetAutoTime(a float64) {
|
||||
autolock.Lock()
|
||||
autotime = a
|
||||
autolock.Unlock()
|
||||
|
|
@ -27,10 +27,10 @@ func StartAutoSave() {
|
|||
autolock.Lock()
|
||||
a := autotime
|
||||
autolock.Unlock()
|
||||
if a < 1 {
|
||||
if a <= 0 {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Duration(a) * time.Second)
|
||||
time.Sleep(time.Duration(a * float64(time.Second)))
|
||||
Autosave <- true
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Reference in a new issue