Skip to content

Commit 6227691

Browse files
committed
Potential fix for downgrade prompts.
1 parent 08439c6 commit 6227691

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

indra/newview/llvelopack.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,10 @@ static void on_vpk_log(void* p_user_data,
659659
// Version comparison helper
660660
//
661661

662-
static bool is_below_version(const std::string& vvm_version)
662+
// Compare running version against a VVM version string "major.minor.patch.build".
663+
// Returns -1 if running < vvm, 0 if equal, 1 if running > vvm.
664+
static int compare_running_version(const std::string& vvm_version)
663665
{
664-
// Parse VVM version "major.minor.patch.build" and compare against running version
665666
S32 major = 0, minor = 0, patch = 0;
666667
U64 build = 0;
667668
sscanf(vvm_version.c_str(), "%d.%d.%d.%llu", &major, &minor, &patch, &build);
@@ -672,10 +673,11 @@ static bool is_below_version(const std::string& vvm_version)
672673
S32 cur_patch = vi.getPatch();
673674
U64 cur_build = vi.getBuild();
674675

675-
if (cur_major != major) return cur_major < major;
676-
if (cur_minor != minor) return cur_minor < minor;
677-
if (cur_patch != patch) return cur_patch < patch;
678-
return cur_build < build;
676+
if (cur_major != major) return cur_major < major ? -1 : 1;
677+
if (cur_minor != minor) return cur_minor < minor ? -1 : 1;
678+
if (cur_patch != patch) return cur_patch < patch ? -1 : 1;
679+
if (cur_build != build) return cur_build < build ? -1 : 1;
680+
return 0;
679681
}
680682

681683
//
@@ -877,9 +879,12 @@ void velopack_check_for_updates(const std::string& required_version, const std::
877879
return;
878880
}
879881

880-
// Determine if a required version means we need to allow downgrades
882+
// Allow downgrades only for rollbacks: VVM requires a version that's
883+
// strictly lower than what we're running (e.g., a retracted build).
881884
bool has_required = !required_version.empty();
882-
ensure_update_manager(has_required);
885+
int ver_cmp = has_required ? compare_running_version(required_version) : 0;
886+
bool allow_downgrade = ver_cmp > 0; // running > required → rollback scenario
887+
ensure_update_manager(allow_downgrade);
883888
if (!sUpdateManager)
884889
return;
885890

@@ -909,7 +914,7 @@ void velopack_check_for_updates(const std::string& required_version, const std::
909914
sPendingCheckInfo = update_info;
910915

911916
// Determine if this is mandatory: running version is below VVM's required floor
912-
bool is_required = has_required && is_below_version(required_version);
917+
bool is_required = ver_cmp < 0; // running < required → must update
913918
sIsRequired = is_required;
914919

915920
if (is_required)

0 commit comments

Comments
 (0)