config: Use float64 within the autosave processing

This commit is contained in:
Jöran Karl 2024-06-19 21:10:52 +02:00
parent 832c7deaf8
commit 4170df89eb
3 changed files with 6 additions and 6 deletions

View file

@ -357,7 +357,7 @@ func main() {
}
if a := config.GetGlobalOption("autosave").(float64); a > 0 {
config.SetAutoTime(int(a))
config.SetAutoTime(a)
config.StartAutoSave()
}

View file

@ -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)

View file

@ -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
}
}()