diff --git a/pcsx2-qt/AutoUpdaterDialog.cpp b/pcsx2-qt/AutoUpdaterDialog.cpp index 8d18a7c0f5704..dd591898b94c2 100644 --- a/pcsx2-qt/AutoUpdaterDialog.cpp +++ b/pcsx2-qt/AutoUpdaterDialog.cpp @@ -24,6 +24,7 @@ #include "cpuinfo.h" #include +#include #include #include #include @@ -640,8 +641,8 @@ bool AutoUpdaterDialog::doUpdate(const std::string& application_dir, const std:: const std::wstring wupdater_path = StringUtil::UTF8StringToWideString(updater_path); const std::wstring wapplication_dir = StringUtil::UTF8StringToWideString(application_dir); - const std::wstring arguments = StringUtil::UTF8StringToWideString(fmt::format("{} \"{}\" \"{}\" \"{}\"", - QCoreApplication::applicationPid(), application_dir, zip_path, program_path)); + const std::wstring arguments = StringUtil::UTF8StringToWideString(fmt::format("{} \"{}\" \"{}\" \"{}\" \"{}\" \"{}\"", + QCoreApplication::applicationPid(), application_dir, zip_path, program_path, BuildVersion::GitRev, m_latest_version.toStdString())); const bool needs_elevation = doesUpdaterNeedElevation(application_dir); @@ -756,6 +757,18 @@ bool AutoUpdaterDialog::processUpdate(const std::vector& data, QProgressDial return false; } + // Log the version transition for regression bisecting + if (auto fp = FileSystem::OpenManagedCFile( + Path::Combine(EmuFolders::DataRoot, "update_log.txt").c_str(), "ab")) + { + const std::time_t t = std::time(nullptr); + char timestamp[32]; + std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", std::localtime(&t)); + const std::string entry = fmt::format("[{}] Updated PCSX2 from {} to {}\n", + timestamp, BuildVersion::GitRev, m_latest_version.toStdString()); + std::fwrite(entry.c_str(), 1, entry.size(), fp.get()); + } + // We exit once we return. return true; } @@ -894,6 +907,19 @@ bool AutoUpdaterDialog::processUpdate(const std::vector& data, QProgressDial reportError("Failed to start new application"); return false; } + + // Log the version transition for regression bisecting + if (auto fp = FileSystem::OpenManagedCFile( + Path::Combine(EmuFolders::DataRoot, "update_log.txt").c_str(), "ab")) + { + const std::time_t t = std::time(nullptr); + char timestamp[32]; + std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", std::localtime(&t)); + const std::string entry = fmt::format("[{}] Updated PCSX2 from {} to {}\n", + timestamp, BuildVersion::GitRev, m_latest_version.toStdString()); + std::fwrite(entry.c_str(), 1, entry.size(), fp.get()); + } + return true; } diff --git a/updater/Windows/WindowsUpdater.cpp b/updater/Windows/WindowsUpdater.cpp index ad4a8027e27b6..9423ed16eeab2 100644 --- a/updater/Windows/WindowsUpdater.cpp +++ b/updater/Windows/WindowsUpdater.cpp @@ -10,6 +10,9 @@ #include "common/StringUtil.h" #include "common/ProgressCallback.h" #include "common/RedtapeWilCom.h" +#include "common/Path.h" +#include +#include #include #include @@ -433,10 +436,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi progress.ModalError("Failed to parse command line."); return 1; } - if (argc != 5) + if (argc != 7) { - progress.ModalError("Expected 4 arguments: parent process id, output directory, update zip, program to " - "launch.\n\nThis program is not intended to be run manually, please use the main PCSX2 application and " + progress.ModalError("Expected 6 arguments: parent process id, output directory, update zip, program to " + "launch, old version, new version.\n\nThis program is not intended to be run manually, please use the main PCSX2 application and " "click Help->Check for Updates."); return 1; } @@ -445,6 +448,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi const std::string destination_directory = StringUtil::WideStringToUTF8String(argv[2]); const std::string zip_path = StringUtil::WideStringToUTF8String(argv[3]); const std::wstring program_to_launch(argv[4]); + const std::string old_version = StringUtil::WideStringToUTF8String(argv[5]); + const std::string new_version = StringUtil::WideStringToUTF8String(argv[6]); argv.reset(); if (parent_process_id <= 0 || destination_directory.empty() || zip_path.empty() || program_to_launch.empty()) @@ -494,6 +499,18 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi updater.CleanupStagingDirectory(); updater.RemoveUpdateZip(); + // Log the version transition for regression bisecting + if (!old_version.empty() && !new_version.empty()) + { + const std::string log_path = Path::Combine(destination_directory, "update_log.txt"); + const std::time_t t = std::time(nullptr); + char timestamp[32]; + std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", std::localtime(&t)); + const std::string entry = fmt::format("[{}] Updated PCSX2 from {} to {}\n", timestamp, old_version, new_version); + if (auto fp = FileSystem::OpenManagedCFile(log_path.c_str(), "ab")) + std::fwrite(entry.c_str(), 1, entry.size(), fp.get()); + } + // Rename the new executable to match the existing one if (std::string actual_exe = updater.FindPCSX2Exe(); !actual_exe.empty()) {