summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorDentomologist <dentomologist@gmail.com>2022-10-31 23:08:35 -0700
committerDentomologist <dentomologist@gmail.com>2022-10-31 23:36:07 -0700
commit7cd08fde755cc2ef4f510730f6c1650fef05bf15 (patch)
treeea2348f6d3fd3c03718d5963742fa00c4ad4fa2e /Source
parent2808db7f2fb48d0a1e1cb17aac6d39fc2a521560 (diff)
Updater: Add/clarify error messages
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/MenuBar.cpp7
-rw-r--r--Source/Core/DolphinQt/Updater.cpp12
-rw-r--r--Source/Core/DolphinQt/Updater.h2
-rw-r--r--Source/Core/UICommon/AutoUpdate.cpp33
-rw-r--r--Source/Core/UICommon/AutoUpdate.h8
5 files changed, 39 insertions, 23 deletions
diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp
index f36a1d9a1d..4631a5e366 100644
--- a/Source/Core/DolphinQt/MenuBar.cpp
+++ b/Source/Core/DolphinQt/MenuBar.cpp
@@ -558,12 +558,7 @@ void MenuBar::InstallUpdateManually()
auto* const updater = new Updater(this->parentWidget(), manual_track,
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
- if (!updater->CheckForUpdate())
- {
- ModalMessageBox::information(
- this, tr("Update"),
- tr("You are running the latest version available on this update track."));
- }
+ updater->CheckForUpdate();
}
void MenuBar::AddHelpMenu()
diff --git a/Source/Core/DolphinQt/Updater.cpp b/Source/Core/DolphinQt/Updater.cpp
index 256a8f59c1..0827c0c104 100644
--- a/Source/Core/DolphinQt/Updater.cpp
+++ b/Source/Core/DolphinQt/Updater.cpp
@@ -29,21 +29,19 @@ Updater::Updater(QWidget* parent, std::string update_track, std::string hash_ove
void Updater::run()
{
- AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override);
+ AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
+ AutoUpdateChecker::CheckType::Automatic);
}
-bool Updater::CheckForUpdate()
+void Updater::CheckForUpdate()
{
- m_update_available = false;
- AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override);
-
- return m_update_available;
+ AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
+ AutoUpdateChecker::CheckType::Manual);
}
void Updater::OnUpdateAvailable(const NewVersionInformation& info)
{
bool later = false;
- m_update_available = true;
std::optional<int> choice = RunOnObject(m_parent, [&] {
QDialog* dialog = new QDialog(m_parent);
diff --git a/Source/Core/DolphinQt/Updater.h b/Source/Core/DolphinQt/Updater.h
index a725e2019b..6c564d86a7 100644
--- a/Source/Core/DolphinQt/Updater.h
+++ b/Source/Core/DolphinQt/Updater.h
@@ -21,7 +21,7 @@ public:
void run() override;
void OnUpdateAvailable(const NewVersionInformation& info) override;
- bool CheckForUpdate();
+ void CheckForUpdate();
private:
QWidget* m_parent;
diff --git a/Source/Core/UICommon/AutoUpdate.cpp b/Source/Core/UICommon/AutoUpdate.cpp
index d54a488c46..35b17ed19d 100644
--- a/Source/Core/UICommon/AutoUpdate.cpp
+++ b/Source/Core/UICommon/AutoUpdate.cpp
@@ -8,10 +8,12 @@
#include <fmt/format.h>
#include <picojson.h>
+#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/HttpRequest.h"
#include "Common/Logging/Log.h"
+#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Version.h"
@@ -159,7 +161,7 @@ static std::string GetPlatformID()
}
void AutoUpdateChecker::CheckForUpdate(std::string_view update_track,
- std::string_view hash_override)
+ std::string_view hash_override, const CheckType check_type)
{
// Don't bother checking if updates are not supported or not enabled.
if (!SystemSupportsAutoUpdates() || update_track.empty())
@@ -173,11 +175,14 @@ void AutoUpdateChecker::CheckForUpdate(std::string_view update_track,
std::string url = fmt::format("https://dolphin-emu.org/update/check/v1/{}/{}/{}", update_track,
version_hash, GetPlatformID());
+ const bool is_manual_check = check_type == CheckType::Manual;
+
Common::HttpRequest req{std::chrono::seconds{10}};
auto resp = req.Get(url);
if (!resp)
{
- ERROR_LOG_FMT(COMMON, "Auto-update request failed");
+ if (is_manual_check)
+ CriticalAlertFmtT("Unable to contact update server.");
return;
}
const std::string contents(reinterpret_cast<char*>(resp->data()), resp->size());
@@ -187,13 +192,15 @@ void AutoUpdateChecker::CheckForUpdate(std::string_view update_track,
const std::string err = picojson::parse(json, contents);
if (!err.empty())
{
- ERROR_LOG_FMT(COMMON, "Invalid JSON received from auto-update service: {}", err);
+ CriticalAlertFmtT("Invalid JSON received from auto-update service : {0}", err);
return;
}
picojson::object obj = json.get<picojson::object>();
if (obj["status"].get<std::string>() != "outdated")
{
+ if (is_manual_check)
+ SuccessAlertFmtT("You are running the latest version available on this update track.");
INFO_LOG_FMT(COMMON, "Auto-update status: we are up to date.");
return;
}
@@ -212,7 +219,7 @@ void AutoUpdateChecker::CheckForUpdate(std::string_view update_track,
}
void AutoUpdateChecker::TriggerUpdate(const AutoUpdateChecker::NewVersionInformation& info,
- AutoUpdateChecker::RestartMode restart_mode)
+ const AutoUpdateChecker::RestartMode restart_mode)
{
// Check to make sure we don't already have an update triggered
if (s_update_triggered)
@@ -241,8 +248,16 @@ void AutoUpdateChecker::TriggerUpdate(const AutoUpdateChecker::NewVersionInforma
#ifdef __APPLE__
// Copy the updater so it can update itself if needed.
const std::string reloc_updater_path = UpdaterPath(true);
- File::CopyDir(UpdaterPath(), reloc_updater_path);
- chmod((reloc_updater_path + UPDATER_CONTENT_PATH).c_str(), 0700);
+ if (!File::CopyDir(UpdaterPath(), reloc_updater_path))
+ {
+ CriticalAlertFmtT("Unable to create updater copy.");
+ return;
+ }
+ if (chmod((reloc_updater_path + UPDATER_CONTENT_PATH).c_str(), 0700) != 0)
+ {
+ CriticalAlertFmtT("Unable to set permissions on updater copy.");
+ return;
+ }
#endif
// Run the updater!
@@ -261,12 +276,14 @@ void AutoUpdateChecker::TriggerUpdate(const AutoUpdateChecker::NewVersionInforma
}
else
{
- ERROR_LOG_FMT(COMMON, "Could not start updater process: error={}", GetLastError());
+ const std::string error = GetLastErrorString();
+ CriticalAlertFmtT("Could not start updater process: {0}", error);
}
#else
if (popen(command_line.c_str(), "r") == nullptr)
{
- ERROR_LOG_FMT(COMMON, "Could not start updater process: error={}", errno);
+ const std::string error = LastStrerrorString();
+ CriticalAlertFmtT("Could not start updater process: {0}", error);
}
#endif
diff --git a/Source/Core/UICommon/AutoUpdate.h b/Source/Core/UICommon/AutoUpdate.h
index d46b82b9ae..9a957bff93 100644
--- a/Source/Core/UICommon/AutoUpdate.h
+++ b/Source/Core/UICommon/AutoUpdate.h
@@ -13,9 +13,15 @@
class AutoUpdateChecker
{
public:
+ enum class CheckType
+ {
+ Automatic,
+ Manual,
+ };
// Initiates a check for updates in the background. Calls the OnUpdateAvailable callback if an
// update is available, does "nothing" otherwise.
- void CheckForUpdate(std::string_view update_track, std::string_view hash_override);
+ void CheckForUpdate(std::string_view update_track, std::string_view hash_override,
+ CheckType check_type);
static bool SystemSupportsAutoUpdates();