Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: write version changes to update_history.log #10972

Merged
merged 2 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions rpcs3/rpcs3qt/update_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ bool update_manager::handle_json(bool automatic, bool check_only, bool auto_acce

const Localized localized;

m_new_version = latest["version"].toString().toStdString();

if (hash_found)
{
m_old_version = current["version"].toString().toStdString();

if (diff_msec < 0)
{
// This usually means that the current version was marked as broken and won't be shipped anymore, so we need to downgrade to avoid certain bugs.
Expand All @@ -197,6 +201,8 @@ bool update_manager::handle_json(bool automatic, bool check_only, bool auto_acce
}
else
{
m_old_version = fmt::format("%s-%s-%s", rpcs3::get_full_branch(), rpcs3::get_branch(), rpcs3::get_version().to_string());

m_update_message = tr("You're currently using a custom or PR build.\n\nLatest version: %0 (%1)\nThe latest version is %2 old.\n\nDo you want to update to the latest official RPCS3 version?")
.arg(latest["version"].toString())
.arg(lts_str)
Expand Down Expand Up @@ -631,6 +637,19 @@ bool update_manager::handle_rpcs3(const QByteArray& data, bool auto_accept)

m_downloader->close_progress_dialog();

// Add new version to log file
if (fs::file update_file{fs::get_config_dir() + "update_history.log", fs::create + fs::write + fs::append})
{
const std::string update_time = QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss").toStdString();
const std::string entry = fmt::format("%s: Updated from \"%s\" to \"%s\"", update_time, m_old_version, m_new_version);
update_file.write(fmt::format("%s\n", entry));
update_log.notice("Added entry '%s' to update_history.log", entry);
}
else
{
update_log.error("Failed to append version to update_history.log");
}

if (!auto_accept)
{
QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!\nRPCS3 will now restart."));
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3qt/update_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class update_manager final : public QObject

std::string m_request_url;
std::string m_expected_hash;
std::string m_old_version;
std::string m_new_version;
u64 m_expected_size = 0;

bool handle_json(bool automatic, bool check_only, bool auto_accept, const QByteArray& data);
Expand Down