mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Change error msg and use module online check in TriggerUpdate()
This commit is contained in:
parent
30800f7383
commit
65089f47dd
1 changed files with 7 additions and 8 deletions
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/safing/portbase/log"
|
"github.com/safing/portbase/log"
|
||||||
"github.com/safing/portbase/modules"
|
"github.com/safing/portbase/modules"
|
||||||
"github.com/safing/portbase/updater"
|
"github.com/safing/portbase/updater"
|
||||||
"github.com/tevino/abool"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -43,7 +42,7 @@ var (
|
||||||
module *modules.Module
|
module *modules.Module
|
||||||
registry *updater.ResourceRegistry
|
registry *updater.ResourceRegistry
|
||||||
updateTask *modules.Task
|
updateTask *modules.Task
|
||||||
updateASAP = abool.New()
|
updateASAP bool
|
||||||
disableTaskSchedule bool
|
disableTaskSchedule bool
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ func start() error {
|
||||||
Schedule(time.Now().Add(10 * time.Second))
|
Schedule(time.Now().Add(10 * time.Second))
|
||||||
}
|
}
|
||||||
|
|
||||||
if updateASAP.IsSet() {
|
if updateASAP {
|
||||||
updateTask.StartASAP()
|
updateTask.StartASAP()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,14 +130,14 @@ func start() error {
|
||||||
|
|
||||||
// TriggerUpdate queues the update task to execute ASAP.
|
// TriggerUpdate queues the update task to execute ASAP.
|
||||||
func TriggerUpdate() error {
|
func TriggerUpdate() error {
|
||||||
if updateTask == nil {
|
if !module.Online() {
|
||||||
if !module.OnlineSoon() {
|
if !module.OnlineSoon() {
|
||||||
return fmt.Errorf("module not started")
|
return fmt.Errorf("module not enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
updateASAP.Set()
|
updateASAP = true
|
||||||
} else {
|
} else {
|
||||||
updateTask.Queue()
|
updateTask.StartASAP()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -148,7 +147,7 @@ func TriggerUpdate() error {
|
||||||
// If called, updates are only checked when TriggerUpdate()
|
// If called, updates are only checked when TriggerUpdate()
|
||||||
// is called.
|
// is called.
|
||||||
func DisableUpdateSchedule() error {
|
func DisableUpdateSchedule() error {
|
||||||
if module.Online() {
|
if module.OnlineSoon() {
|
||||||
return fmt.Errorf("module already online")
|
return fmt.Errorf("module already online")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue