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:
Roland Winklmeier
2016-02-21 20:13:53 +01:00
parent 17324f718d
commit 61e68860f8

View File

@@ -78,11 +78,12 @@ namespace BlackMisc
nameFilter += QLatin1String("*.log"); nameFilter += QLatin1String("*.log");
QDir dir(m_logPath, nameFilter, QDir::Name, QDir::Files); 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());
} }
} }
} }