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. The downside will be that the file remains readable to the world.
This commit is contained in:
Thomas Piccirello 2025-05-30 18:22:52 -07:00
commit ebc974a1ba
No known key found for this signature in database

View file

@ -175,12 +175,14 @@ 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);
return;
}
// best effort, don't report error
m_logFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
}
void FileLogger::closeLogFile()