Simplify and improve update version export

This commit is contained in:
Daniel
2022-06-21 16:55:19 +02:00
parent b58d7fb858
commit 9f4e921609
2 changed files with 98 additions and 93 deletions

View File

@@ -7,6 +7,7 @@ import (
"runtime"
"time"
"github.com/safing/portbase/database"
"github.com/safing/portbase/dataroot"
"github.com/safing/portbase/log"
"github.com/safing/portbase/modules"
@@ -48,6 +49,11 @@ var (
updateASAP bool
disableTaskSchedule bool
db = database.NewInterface(&database.Options{
Local: true,
Internal: true,
})
// UserAgent is an HTTP User-Agent that is used to add
// more context to requests made by the registry when
// fetching resources from the update server.
@@ -55,6 +61,8 @@ var (
)
const (
updatesDirName = "updates"
updateFailed = "updates:failed"
updateSuccess = "updates:success"
)
@@ -108,7 +116,7 @@ func start() error {
registry.UserAgent = userAgentFromFlag
}
// initialize
err := registry.Initialize(dataroot.Root().ChildDir("updates", 0o0755))
err := registry.Initialize(dataroot.Root().ChildDir(updatesDirName, 0o0755))
if err != nil {
return err
}
@@ -275,7 +283,7 @@ func stop() error {
}
}
return stopVersionExport()
return nil
}
// RootPath returns the root path used for storing updates.