Make modifying log file perms best effort

qBittorrent is able to write to the log file, so it's ok if the permission change fails.

PR #22800.
This commit is contained in:
Thomas Piccirello 2025-06-05 02:32:26 -07:00 committed by GitHub
parent 0c48b70e5b
commit c59ac3b970
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -175,12 +175,15 @@ void FileLogger::flushLog()
void FileLogger::openLogFile()
{
if (!m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)
|| !m_logFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner))
if (!m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
{
m_logFile.close();
LogMsg(tr("An error occurred while trying to open the log file. Logging to file is disabled."), Log::CRITICAL);
LogMsg(tr("An error occurred while trying to open the log file. Logging to file is disabled. File: \"%1\". Error: \"%2\".")
.arg(m_logFile.fileName(), m_logFile.errorString()), Log::CRITICAL);
return;
}
// best effort, don't report error
m_logFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
}
void FileLogger::closeLogFile()