Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions pcsx2-qt/AutoUpdaterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "cpuinfo.h"

#include <functional>
#include <ctime>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QFile>
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -756,6 +757,18 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& 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;
}
Expand Down Expand Up @@ -894,6 +907,19 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& 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;
}

Expand Down
23 changes: 20 additions & 3 deletions updater/Windows/WindowsUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "common/StringUtil.h"
#include "common/ProgressCallback.h"
#include "common/RedtapeWilCom.h"
#include "common/Path.h"
#include <fmt/format.h>
#include <ctime>

#include <CommCtrl.h>
#include <shellapi.h>
Expand Down Expand Up @@ -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;
}
Expand All @@ -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())
Expand Down Expand Up @@ -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())
{
Expand Down
Loading