mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 07:15:34 +08:00
Fix removing of old log files
The modification date of the log files was invalid, since QFileInfo was constructed with a filename only and absolute path. Hence no file was ever removed from disk.
This commit is contained in:
@@ -78,11 +78,12 @@ namespace BlackMisc
|
||||
nameFilter += QLatin1String("*.log");
|
||||
QDir dir(m_logPath, nameFilter, QDir::Name, QDir::Files);
|
||||
|
||||
for (const auto &logFile : dir.entryList())
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
for (const auto &logFileInfo : dir.entryInfoList())
|
||||
{
|
||||
if (QFileInfo(logFile).lastModified().daysTo(QDateTime::currentDateTime()) > 7 )
|
||||
if (logFileInfo.lastModified().daysTo(now) > 7 )
|
||||
{
|
||||
dir.remove(logFile);
|
||||
dir.remove(logFileInfo.fileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user