Skip to content

Commit

Permalink
Qt: write version changes to update.log
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Oct 9, 2021
1 parent 8e31127 commit c589978
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit c589978

Please sign in to comment.