diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-06-01 23:48:48 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-06-01 23:48:48 +0300 |
commit | 3a6657596ba19a0310df38ed0c94f292c2de68c9 (patch) | |
tree | f41abf9588adcfe21d6d628701f3fe55d2d2d7cc /launcher/Application.cpp | |
parent | 6c082403c4e910248a41fd84a1a48522484be2cf (diff) | |
download | PrismLauncher-3a6657596ba19a0310df38ed0c94f292c2de68c9.tar.gz PrismLauncher-3a6657596ba19a0310df38ed0c94f292c2de68c9.tar.bz2 PrismLauncher-3a6657596ba19a0310df38ed0c94f292c2de68c9.zip |
Added migration for old logs
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r-- | launcher/Application.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 026d1636..e9a3cb89 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -376,9 +376,18 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) // init the logger { - static const QString logBase = FS::PathCombine("logs", BuildConfig.LAUNCHER_NAME + "-%0.log"); - FS::ensureFolderPathExists( - "logs"); // this can fail, but there is no need to throw an error *yet*, since it also triggers the error message below! + static const QString baseLogFile = BuildConfig.LAUNCHER_NAME + "-%0.log"; + static const QString logBase = FS::PathCombine("logs", baseLogFile); + if (FS::ensureFolderPathExists("logs")) { // if this did not fail + for (auto i = 0; i <= 4; i++) { + auto oldName = baseLogFile.arg(i); + auto newName = logBase.arg(i); + if (QFile::exists(newName)) // in case there are already files in folder just to be safe add a suffix + newName += ".old"; + QFile::rename(oldName, newName); + } + } + auto moveFile = [](const QString& oldName, const QString& newName) { QFile::remove(newName); QFile::copy(oldName, newName); |