diff --git a/src/main.cpp b/src/main.cpp index ac80aa15f..669bc6c61 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,11 +159,6 @@ void createLogFile(const Paths& paths) QFileInfo logFile{logFilePath}; QDir logFileDir{logFile.dir()}; - if (!logFileDir.mkpath(".")) { - qCritical() << "Couldn't create path for log file"; - return; - } - QByteArray logFilePathLocal{logFile.absoluteFilePath().toLocal8Bit()}; FILE* mainLogFilePtr = fopen(logFilePathLocal.constData(), "a"); diff --git a/src/persistence/paths.cpp b/src/persistence/paths.cpp index 33f71547d..0b8275735 100644 --- a/src/persistence/paths.cpp +++ b/src/persistence/paths.cpp @@ -101,7 +101,23 @@ Paths* Paths::makePaths(Portable mode) Paths::Paths(const QString& basePath, bool portable) : basePath{basePath} , portable{portable} -{} +{ + QStringList allDirs{ + getGlobalSettingsPath(), + getLogFilePath(), + getProfilesDir(), + getToxSaveDir(), + getAvatarsDir(), + getTransfersDir(), + getScreenshotsDir() + }; + allDirs += getThemeDirs(); + for (auto& dir : allDirs) { + if (!QDir{}.mkpath(dir)) { + qCritical() << "Couldn't create dir:" << dir; + } + } +} /** * @brief Check if qTox is running in portable mode. diff --git a/src/persistence/profile.cpp b/src/persistence/profile.cpp index 485a93e59..a41b69ba8 100644 --- a/src/persistence/profile.cpp +++ b/src/persistence/profile.cpp @@ -608,7 +608,6 @@ void Profile::saveAvatar(const ToxPk& owner, const QByteArray& avatar) const QByteArray& pic = needEncrypt ? passkey->encrypt(avatar) : avatar; QString path = avatarPath(owner); - QDir{}.mkpath(Settings::getInstance().getPaths().getAvatarsDir()); if (pic.isEmpty()) { QFile::remove(path); } else { diff --git a/src/persistence/settings.cpp b/src/persistence/settings.cpp index 902a6aeb0..3edd697fa 100644 --- a/src/persistence/settings.cpp +++ b/src/persistence/settings.cpp @@ -110,8 +110,6 @@ void Settings::loadGlobal() if (loaded) return; - createSettingsDir(); - QString filePath = paths.getGlobalSettingsPath(); // If no settings file exist -- use the default one @@ -2314,19 +2312,6 @@ void Settings::createPersonal(QString basename) ps.endGroup(); } -/** - * @brief Creates a path to the settings dir, if it doesn't already exist - */ -void Settings::createSettingsDir() -{ - QMutexLocker locker{&bigLock}; - - QString dir = Settings::getSettingsDirPath(); - QDir directory(dir); - if (!directory.exists() && !directory.mkpath(directory.absolutePath())) - qCritical() << "Error while creating directory " << dir; -} - /** * @brief Waits for all asynchronous operations to complete */ diff --git a/src/persistence/settings.h b/src/persistence/settings.h index e951ab8c0..621c6a444 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -139,7 +139,6 @@ public: ~Settings() override; static Settings& getInstance(); - void createSettingsDir(); void createPersonal(QString basename); void savePersonal();