Skip to content

Commit 76236a7

Browse files
committed
Enable velopack downgrade and skip older updates
1 parent eb7d968 commit 76236a7

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

indra/newview/llvelopack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ bool velopack_initialize()
669669
return true;
670670
}
671671

672-
static void velopack_download_update()
672+
static void velopack_download_update(bool allow_downgrade = false)
673673
{
674674
if (sUpdateUrl.empty())
675675
{
@@ -680,7 +680,7 @@ static void velopack_download_update()
680680
if (!sUpdateManager)
681681
{
682682
vpkc_update_options_t options = {};
683-
options.AllowVersionDowngrade = false;
683+
options.AllowVersionDowngrade = allow_downgrade;
684684
options.ExplicitChannel = nullptr;
685685

686686
if (!sUpdateSource)
@@ -798,7 +798,7 @@ static void on_required_update_response(const LLSD& notification, const LLSD& re
798798
show_downloading_notification(version);
799799
LLCoros::instance().launch("VelopackRequiredUpdate", []()
800800
{
801-
velopack_download_update();
801+
velopack_download_update(true /* allow_downgrade for rollbacks */);
802802
dismiss_downloading_notification();
803803
if (velopack_is_update_pending())
804804
{

indra/newview/llvvmquery.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llviewerprecompiledheaders.h"
2828
#include "llvvmquery.h"
2929

30+
#include <tuple>
3031
#include "llcorehttputil.h"
3132
#include "llcoros.h"
3233
#include "llevents.h"
@@ -143,13 +144,28 @@ namespace
143144
#if LL_VELOPACK
144145
std::string velopack_url = platforms[platform]["velopack_url"].asString();
145146
U32 updater_service = gSavedSettings.getU32("UpdaterServiceSetting");
146-
if (!velopack_url.empty() && (update_required || updater_service != 0))
147+
std::string update_version = result["version"].asString();
148+
const LLVersionInfo& vi = LLVersionInfo::instance();
149+
S32 cur[] = { vi.getMajor(), vi.getMinor(), vi.getPatch() };
150+
U64 cur_build = vi.getBuild();
151+
S32 upd[] = { 0, 0, 0 };
152+
U64 upd_build = 0;
153+
sscanf(update_version.c_str(), "%d.%d.%d.%llu",
154+
&upd[0], &upd[1], &upd[2], &upd_build);
155+
bool is_newer = std::tie(upd[0], upd[1], upd[2], upd_build)
156+
> std::tie(cur[0], cur[1], cur[2], cur_build);
157+
if (!velopack_url.empty() && !is_newer && !update_required)
158+
{
159+
LL_INFOS("VVM") << "VVM version " << update_version
160+
<< " is not newer than running version " << version
161+
<< ", skipping optional update" << LL_ENDL;
162+
}
163+
else if (!velopack_url.empty() && (update_required || updater_service != 0))
147164
{
148165
LL_INFOS("VVM") << "Velopack update URL: " << velopack_url
149166
<< " required: " << update_required << LL_ENDL;
150167
velopack_set_update_url(velopack_url);
151168

152-
std::string update_version = result["version"].asString();
153169
LLCoros::instance().launch("VelopackUpdateCheck",
154170
[update_required, update_version, relnotes]()
155171
{

0 commit comments

Comments
 (0)