From cd79d120d863b25da3cbf3287863d675ae6f3ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 6 Sep 2023 10:34:32 +0200 Subject: [PATCH] Don't log warnings on missing RA login secret. Also don't even check unless a username has been set. --- Common/System/NativeApp.h | 4 +++- Core/RetroAchievements.cpp | 4 ++-- UI/NativeApp.cpp | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index 41b9e5a0a6..94a67c9eb9 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -80,5 +80,7 @@ void NativeShutdown(); void PostLoadConfig(); -void NativeSaveSecret(const char *nameOfSecret, const std::string &data); +// Returns false on failure. Shouldn't really happen, though. +bool NativeSaveSecret(const char *nameOfSecret, const std::string &data); +// On failure, returns an empty string. Good enough since any real secret is non-empty. std::string NativeLoadSecret(const char *nameOfSecret); diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index 1f3a7211e6..f2e5d1fbac 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -536,8 +536,8 @@ void Idle() { if (g_rcClient && IsLoggedIn()) { return; // All good. } - if (!HasToken() || g_isLoggingIn) { - // Didn't login yet or is in the process of logging in. Also OK. + if (g_Config.sAchievementsUserName.empty() || g_isLoggingIn || !HasToken()) { + // Didn't try to login yet or is in the process of logging in. Also OK. return; } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 6f1ffc5f73..618c430d75 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1465,18 +1465,21 @@ static Path GetSecretPath(const char *nameOfSecret) { } // name should be simple alphanumerics to avoid problems on Windows. -void NativeSaveSecret(const char *nameOfSecret, const std::string &data) { +bool NativeSaveSecret(const char *nameOfSecret, const std::string &data) { Path path = GetSecretPath(nameOfSecret); if (!File::WriteDataToFile(false, data.data(), (unsigned int)data.size(), path)) { WARN_LOG(SYSTEM, "Failed to write secret '%s' to path '%s'", nameOfSecret, path.c_str()); + return false; } + return true; } +// On failure, returns an empty string. Good enough since any real secret is non-empty. std::string NativeLoadSecret(const char *nameOfSecret) { Path path = GetSecretPath(nameOfSecret); std::string data; if (!File::ReadFileToString(false, path, data)) { - WARN_LOG(SYSTEM, "Failed to read secret '%s' from path '%s'", nameOfSecret, path.c_str()); + data.clear(); // just to be sure. } return data; }