diff --git a/client/internal/updatemanager/update_windows.go b/client/internal/updatemanager/update_windows.go index 39eb3b89f..0164ae486 100644 --- a/client/internal/updatemanager/update_windows.go +++ b/client/internal/updatemanager/update_windows.go @@ -19,7 +19,19 @@ const ( uninstallKeyPath32 = `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Netbird` ) -func (u *UpdateManager) installationMethod() string { +func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error { + method := installation() + switch method { + case "EXE": + return updateEXE(ctx, targetVersion) + case "MSI": + return updateMSI(ctx, targetVersion) + default: + return fmt.Errorf("unsupported installation method: %s", method) + } +} + +func installation() string { k, err := registry.OpenKey(registry.LOCAL_MACHINE, uninstallKeyPath64, registry.QUERY_VALUE) if err != nil { k, err = registry.OpenKey(registry.LOCAL_MACHINE, uninstallKeyPath32, registry.QUERY_VALUE) @@ -64,14 +76,3 @@ func updateEXE(ctx context.Context, targetVersion string) error { return err } - -func triggerUpdate(ctx context.Context, targetVersion string) error { - switch installationMethod() { - case "EXE": - return updateEXE(ctx, targetVersion) - case "MSI": - return updateMSI(ctx, targetVersion) - default: - return fmt.Errorf("unsupported installation method: %s", installationMethod()) - } -}