Use a standardised locale to create log file filenames, fixing issues with certain...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 31 Aug 2023 05:36:10 +0000 (13:36 +0800)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Wed, 13 Sep 2023 12:08:13 +0000 (14:08 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/logger.cpp

index 7a050a10360849c8c3b6567ade44ff0fd5491f20..2bfaa8aaf614763904e8b09d192a7b9c82cab982 100644 (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) +