Use a standardised locale to create log file filenames, fixing issues with certain locales

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-08-31 13:36:10 +08:00
parent 51bb960418
commit 97301e3a55

View file

@ -289,8 +289,9 @@ void Logger::enterNextLogFileNoLock()
}
// Tentative new log name, will be adjusted if one like this already exists
QDateTime now = QDateTime::currentDateTime();
QString newLogName = now.toString("yyyyMMdd_HHmm") + "_nextcloud.log";
const auto now = QDateTime::currentDateTime();
const auto cLocale = QLocale::c(); // Some system locales generate strings that are incompatible with filesystem
QString newLogName = cLocale.toString(now, QStringLiteral("yyyyMMdd_HHmm")) + QStringLiteral("_nextcloud.log");
// Expire old log files and deal with conflicts
QStringList files = dir.entryList(QStringList("*owncloud.log.*"), QDir::Files, QDir::Name) +