Check if we're in the process of restarting when trying to open the log
This commit is contained in:
+18
-5
@@ -325,16 +325,25 @@ logs::file_writer::file_writer(const std::string& name)
|
|||||||
const std::string log_name = fs::get_cache_dir() + name + ".log";
|
const std::string log_name = fs::get_cache_dir() + name + ".log";
|
||||||
const std::string buf_name = fs::get_cache_dir() + name + ".buf";
|
const std::string buf_name = fs::get_cache_dir() + name + ".buf";
|
||||||
|
|
||||||
|
const std::string s_filelock = fs::get_cache_dir() + ".restart_lock";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!m_file.open(buf_name, fs::read + fs::rewrite + fs::lock))
|
if (!m_file.open(buf_name, fs::read + fs::rewrite + fs::lock))
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows does not close all handles before starting a new process with execl
|
if (fs::exists(s_filelock))
|
||||||
// We delay another check for rpcs3 restart after an update
|
{
|
||||||
// TODO: cleaner solution?
|
// A restart is happening, wait for the file to be accessible
|
||||||
std::this_thread::sleep_for(500ms);
|
u32 tries = 0;
|
||||||
if (!m_file.open(buf_name, fs::read + fs::rewrite + fs::lock))
|
while (!m_file.open(buf_name, fs::read + fs::rewrite + fs::lock) && tries < 100)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
tries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_file)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (fs::g_tls_error == fs::error::acces)
|
if (fs::g_tls_error == fs::error::acces)
|
||||||
@@ -359,6 +368,10 @@ logs::file_writer::file_writer(const std::string& name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
fs::remove_file(s_filelock); // remove restart token if it exists
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check free space
|
// Check free space
|
||||||
fs::device_stat stats{};
|
fs::device_stat stats{};
|
||||||
if (!fs::statfs(fs::get_cache_dir(), stats) || stats.avail_free < s_log_size * 8)
|
if (!fs::statfs(fs::get_cache_dir(), stats) || stats.avail_free < s_log_size * 8)
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ void update_manager::handle_error(QNetworkReply::NetworkError error)
|
|||||||
{
|
{
|
||||||
if (error != QNetworkReply::NoError)
|
if (error != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply *>(sender());
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
if(!reply)
|
if (!reply)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_progress_dialog->close();
|
m_progress_dialog->close();
|
||||||
@@ -543,13 +543,16 @@ bool update_manager::handle_rpcs3(const QByteArray& rpcs3_data, bool automatic)
|
|||||||
|
|
||||||
replace_path = Emulator::GetEmuDir() + "rpcs3.exe";
|
replace_path = Emulator::GetEmuDir() + "rpcs3.exe";
|
||||||
|
|
||||||
|
// Creating a file to indicate we're restarting
|
||||||
|
const std::string s_filelock = fs::get_cache_dir() + ".restart_lock";
|
||||||
|
verify("Restart lock" HERE), !!fs::file(s_filelock, fs::create);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_progress_dialog->close();
|
m_progress_dialog->close();
|
||||||
|
|
||||||
QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!"));
|
QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!"));
|
||||||
int ret = execl(replace_path.c_str(), replace_path.c_str(), nullptr);
|
|
||||||
|
|
||||||
|
int ret = execl(replace_path.c_str(), replace_path.c_str(), nullptr);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "[Auto-updater] Relaunching failed with result: %d(%s)", ret, strerror(errno));
|
LOG_ERROR(GENERAL, "[Auto-updater] Relaunching failed with result: %d(%s)", ret, strerror(errno));
|
||||||
|
|||||||
Reference in New Issue
Block a user