mirror of
https://github.com/safing/portmaster
synced 2025-04-22 03:49:09 +00:00
Merge branch 'fix/updater-fix' into release/v2.0.3
This commit is contained in:
commit
41eb203103
4 changed files with 21 additions and 8 deletions
|
@ -4,13 +4,14 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/safing/portmaster/service/configure"
|
||||||
"github.com/safing/portmaster/service/updates"
|
"github.com/safing/portmaster/service/updates"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
scanConfig = updates.IndexScanConfig{
|
scanConfig = updates.IndexScanConfig{
|
||||||
Name: "Portmaster Binaries",
|
Name: configure.DefaultBinaryIndexName,
|
||||||
PrimaryArtifact: "linux_amd64/portmaster-core",
|
PrimaryArtifact: "linux_amd64/portmaster-core",
|
||||||
BaseURL: "https://updates.safing.io/",
|
BaseURL: "https://updates.safing.io/",
|
||||||
IgnoreFiles: []string{
|
IgnoreFiles: []string{
|
||||||
|
|
|
@ -115,7 +115,7 @@ func MakeUpdateConfigs(svcCfg *ServiceConfig) (binaryUpdateConfig, intelUpdateCo
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "windows":
|
||||||
binaryUpdateConfig = &updates.Config{
|
binaryUpdateConfig = &updates.Config{
|
||||||
Name: "binaries",
|
Name: configure.DefaultBinaryIndexName,
|
||||||
Directory: svcCfg.BinDir,
|
Directory: svcCfg.BinDir,
|
||||||
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_binaries"),
|
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_binaries"),
|
||||||
PurgeDirectory: filepath.Join(svcCfg.BinDir, "upgrade_obsolete_binaries"),
|
PurgeDirectory: filepath.Join(svcCfg.BinDir, "upgrade_obsolete_binaries"),
|
||||||
|
@ -130,7 +130,7 @@ func MakeUpdateConfigs(svcCfg *ServiceConfig) (binaryUpdateConfig, intelUpdateCo
|
||||||
Notify: true,
|
Notify: true,
|
||||||
}
|
}
|
||||||
intelUpdateConfig = &updates.Config{
|
intelUpdateConfig = &updates.Config{
|
||||||
Name: "intel",
|
Name: configure.DefaultIntelIndexName,
|
||||||
Directory: filepath.Join(svcCfg.DataDir, "intel"),
|
Directory: filepath.Join(svcCfg.DataDir, "intel"),
|
||||||
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_intel"),
|
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_intel"),
|
||||||
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_intel"),
|
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_intel"),
|
||||||
|
@ -146,7 +146,7 @@ func MakeUpdateConfigs(svcCfg *ServiceConfig) (binaryUpdateConfig, intelUpdateCo
|
||||||
|
|
||||||
case "linux":
|
case "linux":
|
||||||
binaryUpdateConfig = &updates.Config{
|
binaryUpdateConfig = &updates.Config{
|
||||||
Name: "binaries",
|
Name: configure.DefaultBinaryIndexName,
|
||||||
Directory: svcCfg.BinDir,
|
Directory: svcCfg.BinDir,
|
||||||
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_binaries"),
|
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_binaries"),
|
||||||
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_binaries"),
|
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_binaries"),
|
||||||
|
@ -161,7 +161,7 @@ func MakeUpdateConfigs(svcCfg *ServiceConfig) (binaryUpdateConfig, intelUpdateCo
|
||||||
Notify: true,
|
Notify: true,
|
||||||
}
|
}
|
||||||
intelUpdateConfig = &updates.Config{
|
intelUpdateConfig = &updates.Config{
|
||||||
Name: "intel",
|
Name: configure.DefaultIntelIndexName,
|
||||||
Directory: filepath.Join(svcCfg.DataDir, "intel"),
|
Directory: filepath.Join(svcCfg.DataDir, "intel"),
|
||||||
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_intel"),
|
DownloadDirectory: filepath.Join(svcCfg.DataDir, "download_intel"),
|
||||||
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_intel"),
|
PurgeDirectory: filepath.Join(svcCfg.DataDir, "upgrade_obsolete_intel"),
|
||||||
|
|
|
@ -5,6 +5,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
DefaultBinaryIndexName = "Portmaster Binaries"
|
||||||
|
DefaultIntelIndexName = "intel"
|
||||||
|
|
||||||
DefaultStableBinaryIndexURLs = []string{
|
DefaultStableBinaryIndexURLs = []string{
|
||||||
"https://updates.safing.io/stable.v3.json",
|
"https://updates.safing.io/stable.v3.json",
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/safing/portmaster/base/log"
|
"github.com/safing/portmaster/base/log"
|
||||||
"github.com/safing/portmaster/base/notifications"
|
"github.com/safing/portmaster/base/notifications"
|
||||||
"github.com/safing/portmaster/base/utils"
|
"github.com/safing/portmaster/base/utils"
|
||||||
|
"github.com/safing/portmaster/service/configure"
|
||||||
"github.com/safing/portmaster/service/mgr"
|
"github.com/safing/portmaster/service/mgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -201,11 +202,19 @@ func New(instance instance, name string, cfg Config) (*Updater, error) {
|
||||||
module.corruptedInstallation = fmt.Errorf("invalid index: %w", err)
|
module.corruptedInstallation = fmt.Errorf("invalid index: %w", err)
|
||||||
}
|
}
|
||||||
index, err = GenerateIndexFromDir(cfg.Directory, IndexScanConfig{
|
index, err = GenerateIndexFromDir(cfg.Directory, IndexScanConfig{
|
||||||
|
Name: configure.DefaultBinaryIndexName,
|
||||||
Version: info.VersionNumber(),
|
Version: info.VersionNumber(),
|
||||||
})
|
})
|
||||||
if err == nil && index.init(currentPlatform) == nil {
|
if err == nil {
|
||||||
module.index = index
|
// As the index is generated from the current directory,
|
||||||
return module, nil
|
// we must set the published date to a fixed point in the past.
|
||||||
|
// New indexes will only be considered if their published date is later than the current one.
|
||||||
|
index.Published = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
|
if index.init(currentPlatform) == nil {
|
||||||
|
module.index = index
|
||||||
|
return module, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to empty index.
|
// Fall back to empty index.
|
||||||
|
|
Loading…
Add table
Reference in a new issue