UI: Add File Integrity Check

This commit is contained in:
derrod
2022-07-27 00:34:04 +10:00
committed by Matt Gajownik
parent 3dae4a35a1
commit 9c40e448b6
6 changed files with 83 additions and 15 deletions
+41 -13
View File
@@ -511,6 +511,25 @@ int AutoUpdateThread::queryUpdate(bool localManualUpdate, const char *text_utf8)
return ret;
}
bool AutoUpdateThread::queryRepairSlot()
{
QMessageBox::StandardButton res = OBSMessageBox::question(
App()->GetMainWindow(), QTStr("Updater.RepairConfirm.Title"),
QTStr("Updater.RepairConfirm.Text"),
QMessageBox::Yes | QMessageBox::Cancel);
return res == QMessageBox::Yes;
}
bool AutoUpdateThread::queryRepair()
{
bool ret = false;
QMetaObject::invokeMethod(this, "queryRepairSlot",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, ret));
return ret;
}
void AutoUpdateThread::run()
try {
long responseCode;
@@ -615,11 +634,15 @@ try {
if (!success)
throw string("Failed to parse manifest");
if (!updatesAvailable) {
if (!updatesAvailable && !repairMode) {
if (manualUpdate)
info(QTStr("Updater.NoUpdatesAvailable.Title"),
QTStr("Updater.NoUpdatesAvailable.Text"));
return;
} else if (updatesAvailable && repairMode) {
info(QTStr("Updater.RepairButUpdatesAvailable.Title"),
QTStr("Updater.RepairButUpdatesAvailable.Text"));
return;
}
/* ----------------------------------- *
@@ -627,7 +650,7 @@ try {
int skipUpdateVer = config_get_int(GetGlobalConfig(), "General",
"SkipUpdateVersion");
if (!manualUpdate && updateVer == skipUpdateVer)
if (!manualUpdate && updateVer == skipUpdateVer && !repairMode)
return;
/* ----------------------------------- *
@@ -639,20 +662,25 @@ try {
/* ----------------------------------- *
* query user for update */
int queryResult = queryUpdate(manualUpdate, notes.c_str());
if (repairMode) {
if (!queryRepair())
return;
} else {
int queryResult = queryUpdate(manualUpdate, notes.c_str());
if (queryResult == OBSUpdate::No) {
if (!manualUpdate) {
long long t = (long long)time(nullptr);
if (queryResult == OBSUpdate::No) {
if (!manualUpdate) {
long long t = (long long)time(nullptr);
config_set_int(GetGlobalConfig(), "General",
"LastUpdateCheck", t);
}
return;
} else if (queryResult == OBSUpdate::Skip) {
config_set_int(GetGlobalConfig(), "General",
"LastUpdateCheck", t);
"SkipUpdateVersion", updateVer);
return;
}
return;
} else if (queryResult == OBSUpdate::Skip) {
config_set_int(GetGlobalConfig(), "General",
"SkipUpdateVersion", updateVer);
return;
}
/* ----------------------------------- *