Skip to content

Commit e8ccce1

Browse files
committed
favor easy visibility of common branching code path over happy path
1 parent 96a2305 commit e8ccce1

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

cmd/launcher/launcher/run.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ func Run(ctx context.Context, launcherFlags *flags.LauncherFlags) {
2626
gui.SetStage(gui.StageGetDeploymentConfig, 0)
2727
updater.Prepare(resources.LauncherConfig.DeploymentConfigURL)
2828

29-
bringLauncherToWantedVersion(updater, launcherFlags)
29+
if !IsInstanceInstalledInSystemMode() && !launcherFlags.SkipSelfUpdate {
30+
updateLauncherToLatestVersion(updater, launcherFlags)
31+
}
3032
updateBundles(ctx, updater)
3133

3234
gui.SetStage(gui.StageLaunchApplication, 0)
@@ -65,16 +67,9 @@ func createUpdater(ctx context.Context, handler *gui.GuiDownloadProgressHandler)
6567
return updater
6668
}
6769

68-
func bringLauncherToWantedVersion(updater *bundle.Updater, launcherFlags *flags.LauncherFlags) {
69-
if IsInstanceInstalledInSystemMode() || launcherFlags.SkipSelfUpdate {
70-
return
71-
}
72-
updateLauncherToLatestVersion(updater, launcherFlags)
73-
}
74-
7570
func updateLauncherToLatestVersion(updater *bundle.Updater, launcherFlags *flags.LauncherFlags) {
76-
updater.SetIgnoredSelfUpdateBundleInfoSHAs(resources.LauncherConfig.IgnoreLauncherBundleInfoHashes)
77-
if updater.UpdateSelf() {
71+
updater.SetIgnoredLauncherUpdateBundleInfoSHAs(resources.LauncherConfig.IgnoreLauncherBundleInfoHashes)
72+
if updater.UpdateLauncherToLatestVersion() {
7873
runPostBinaryUpdateProvisioning()
7974
locking.Restart(true, launcherFlags)
8075
}

pkg/launcher/bundle/update_self.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/setlog/trivrost/pkg/system"
1717
)
1818

19-
func (u *Updater) UpdateSelf() (needsRestart bool) {
19+
func (u *Updater) UpdateLauncherToLatestVersion() (madeChanges bool) {
2020
if u.deploymentConfig.GetLauncherUpdateConfig() == nil {
2121
return false
2222
}
@@ -25,7 +25,7 @@ func (u *Updater) UpdateSelf() (needsRestart bool) {
2525
return u.updateProgram(programPath)
2626
}
2727

28-
func (u *Updater) updateProgram(programPath string) (needsRestart bool) {
28+
func (u *Updater) updateProgram(programPath string) (madeChanges bool) {
2929
log.Infof("Calculating local hashes.")
3030
u.announceStatus(DetermineLocalLauncherVersion, 20)
3131
presentState := hashing.MustHash(u.ctx, programPath)
@@ -97,12 +97,12 @@ func (u *Updater) swapBinary(localBinaryPath string, remoteURL string, newFileIn
9797
}
9898
}
9999

100-
func (u *Updater) SetIgnoredSelfUpdateBundleInfoSHAs(ignoreShas []string) {
101-
u.ignoredSelfUpdateBundleInfoSHAs = ignoreShas
100+
func (u *Updater) SetIgnoredLauncherUpdateBundleInfoSHAs(ignoreShas []string) {
101+
u.ignoredLauncherUpdateBundleInfoSHAs = ignoreShas
102102
}
103103

104104
func (u *Updater) IsShaIgnored(sha string) bool {
105-
for _, ignoreSha := range u.ignoredSelfUpdateBundleInfoSHAs {
105+
for _, ignoreSha := range u.ignoredLauncherUpdateBundleInfoSHAs {
106106
if ignoreSha == sha {
107107
return true
108108
}

pkg/launcher/bundle/updater.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ type Updater struct {
2929
deploymentConfig *config.DeploymentConfig
3030
publicKeys []*rsa.PublicKey
3131

32-
bundleUpdateInfos []*BundleUpdateInfo
33-
ignoredSelfUpdateBundleInfoSHAs []string
32+
bundleUpdateInfos []*BundleUpdateInfo
33+
ignoredLauncherUpdateBundleInfoSHAs []string
3434

3535
userBundlesFolderPath string
3636
systemBundlesFolderPath string

0 commit comments

Comments
 (0)