From 330dfaa4d901b771c15ac9a5970eef76879a5650 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 14 Aug 2023 10:56:09 +0400 Subject: [PATCH] Consolidate MoveOldDataFiles path determinition --- Telegram/SourceFiles/logs.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index aa4c60c9a..56c8471b0 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -280,6 +280,9 @@ namespace { bool DebugModeEnabled = false; void MoveOldDataFiles(const QString &wasDir) { + if (wasDir.isEmpty()) { + return; + } QFile data(wasDir + "data"), dataConfig(wasDir + "data_config"), tdataConfig(wasDir + "tdata/config"); if (data.exists() && dataConfig.exists() && !QFileInfo::exists(cWorkingDir() + "data") && !QFileInfo::exists(cWorkingDir() + "data_config")) { // move to home dir LOG(("Copying data to home dir '%1' from '%2'").arg(cWorkingDir(), wasDir)); @@ -351,7 +354,6 @@ void start() { return; } - auto moveOldDataFrom = QString(); auto workingDirChosen = false; if (cAlphaVersion()) { @@ -371,10 +373,6 @@ void start() { #endif // !_DEBUG || OS_MAC_STORE } -#if !defined Q_OS_MAC && !defined _DEBUG // fix first version - moveOldDataFrom = launcher.initialWorkingDir(); -#endif // !Q_OS_MAC && !_DEBUG - #elif defined Q_OS_WINRT // Q_OS_UNIX cForceWorkingDir(psAppDataPath()); @@ -443,12 +441,11 @@ void start() { #ifdef Q_OS_WIN if (cWorkingDir() == psAppDataPath()) { // fix old "Telegram Win (Unofficial)" version - moveOldDataFrom = psAppDataPathOld(); + MoveOldDataFiles(psAppDataPathOld()); } +#elif !defined Q_OS_MAC && !defined _DEBUG // fix first version + MoveOldDataFiles(launcher.initialWorkingDir()); #endif - if (!moveOldDataFrom.isEmpty()) { - MoveOldDataFiles(moveOldDataFrom); - } if (LogsInMemory) { Assert(LogsInMemory != DeletedLogsInMemory);