diff --git a/cmds/portmaster-start/main.go b/cmds/portmaster-start/main.go index 3aca82f6..fa3b6fe2 100644 --- a/cmds/portmaster-start/main.go +++ b/cmds/portmaster-start/main.go @@ -194,9 +194,6 @@ func updateRegistryIndex(mustLoadIndex bool) error { // Set indexes based on the release channel. helper.SetIndexes(registry, releaseChannel) - // Update registry to use pre-releases or not. - registry.SetUsePreReleases(releaseChannel != helper.ReleaseChannelStable) - // Load indexes from disk or network, if needed and desired. err := registry.LoadIndexes(context.Background()) if err != nil { @@ -240,7 +237,7 @@ func getReleaseChannel(dataRoot *utils.DirStructure) string { configData, err := ioutil.ReadFile(filepath.Join(dataRoot.Path, "config.json")) if err != nil { if !os.IsNotExist(err) { - log.Printf("WARNING: failed to read config.json to get release channel: %s", err) + log.Printf("WARNING: failed to read config.json to get release channel: %s\n", err) } return helper.ReleaseChannelStable } @@ -250,9 +247,11 @@ func getReleaseChannel(dataRoot *utils.DirStructure) string { switch channel { case helper.ReleaseChannelStable, helper.ReleaseChannelBeta, - helper.ReleaseChannelStaging: + helper.ReleaseChannelStaging, + helper.ReleaseChannelSpecial: return channel default: + log.Printf("WARNING: config.json has unknown release channel %q, falling back to stable channel\n", channel) return helper.ReleaseChannelStable } } diff --git a/updates/config.go b/updates/config.go index 06d75e84..4677678f 100644 --- a/updates/config.go +++ b/updates/config.go @@ -122,8 +122,8 @@ func updateRegistryConfig(_ context.Context, _ interface{}) error { changed := false if releaseChannel() != previousReleaseChannel { - registry.SetUsePreReleases(releaseChannel() != helper.ReleaseChannelStable) previousReleaseChannel = releaseChannel() + helper.SetIndexes(registry, releaseChannel()) changed = true } diff --git a/updates/helper/indexes.go b/updates/helper/indexes.go index 49b26b63..7420768c 100644 --- a/updates/helper/indexes.go +++ b/updates/helper/indexes.go @@ -13,7 +13,11 @@ const ( ReleaseChannelSpecial = "special" ) +// SetIndexes sets the update registry indexes and also configures the registry +// to use pre-releases based on the channel. func SetIndexes(registry *updater.ResourceRegistry, releaseChannel string) { + usePreReleases := false + // Be reminded that the order is important, as indexes added later will // override the current release from earlier indexes. @@ -32,6 +36,7 @@ func SetIndexes(registry *updater.ResourceRegistry, releaseChannel string) { Path: ReleaseChannelBeta + ".json", PreRelease: true, }) + usePreReleases = true } // Add staging index if in staging channel. @@ -40,6 +45,7 @@ func SetIndexes(registry *updater.ResourceRegistry, releaseChannel string) { Path: ReleaseChannelStaging + ".json", PreRelease: true, }) + usePreReleases = true } // Add special index if in special channel. @@ -55,4 +61,7 @@ func SetIndexes(registry *updater.ResourceRegistry, releaseChannel string) { registry.AddIndex(updater.Index{ Path: "all/intel/intel.json", }) + + // Set pre-release usage. + registry.SetUsePreReleases(usePreReleases) } diff --git a/updates/main.go b/updates/main.go index c1d88814..0cc7a61e 100644 --- a/updates/main.go +++ b/updates/main.go @@ -101,7 +101,6 @@ func start() error { UserAgent: UserAgent, MandatoryUpdates: helper.MandatoryUpdates(), AutoUnpack: helper.AutoUnpackUpdates(), - UsePreReleases: initialReleaseChannel != helper.ReleaseChannelStable, DevMode: devMode(), Online: true, }