Fix autosave not running by default

This commit is contained in:
Zachary Yedidia
2020-10-08 23:33:34 -04:00
parent cfcb2e4577
commit a424a0dca1
2 changed files with 10 additions and 6 deletions

View File

@@ -31,14 +31,13 @@ func GetAutoTime() int {
func StartAutoSave() {
go func() {
for {
if autotime < 1 {
break
}
time.Sleep(time.Duration(autotime) * time.Second)
// it's possible autotime was changed while sleeping
if autotime < 1 {
autolock.Lock()
a := autotime
autolock.Unlock()
if a < 1 {
break
}
time.Sleep(time.Duration(a) * time.Second)
Autosave <- true
}
}()