mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
Fix agent self-update infinite loop due to version prefix mismatch
The agent's CurrentVersion includes the "v" prefix (e.g., "v4.33.1") but the server's /api/agent/version endpoint returns versions without it (e.g., "4.33.1"). This caused the comparison to always fail, triggering an infinite self-update loop every 30 seconds. Normalize both versions by stripping the "v" prefix before comparison. Related to #740
This commit is contained in:
@@ -156,7 +156,10 @@ func (u *Updater) CheckAndUpdate(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if serverVersion == u.cfg.CurrentVersion {
|
||||
// Normalize both versions by stripping "v" prefix for comparison.
|
||||
// Server returns version without prefix (e.g., "4.33.1"), but agent's
|
||||
// CurrentVersion may include it (e.g., "v4.33.1") depending on build.
|
||||
if normalizeVersion(serverVersion) == normalizeVersion(u.cfg.CurrentVersion) {
|
||||
u.logger.Debug().Str("version", u.cfg.CurrentVersion).Msg("Agent is up to date")
|
||||
return
|
||||
}
|
||||
@@ -437,6 +440,11 @@ func (u *Updater) performUpdate(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// normalizeVersion strips the "v" prefix from version strings for comparison.
|
||||
func normalizeVersion(version string) string {
|
||||
return strings.TrimPrefix(strings.TrimSpace(version), "v")
|
||||
}
|
||||
|
||||
// determineArch returns the architecture string for download URLs (e.g., "linux-amd64", "darwin-arm64").
|
||||
func determineArch() string {
|
||||
os := runtime.GOOS
|
||||
|
||||
Reference in New Issue
Block a user