mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(paths): create profile dir before calling ProfileLocker or Profile
Fix failure to create new profile due to profile dir not existing. Move creation outside of Profile class due to ProfileLocker static functions.
This commit is contained in:
parent
d683e3b57a
commit
92d3a3ef38
|
@ -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");
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -139,7 +139,6 @@ public:
|
|||
~Settings() override;
|
||||
static Settings& getInstance();
|
||||
|
||||
void createSettingsDir();
|
||||
void createPersonal(QString basename);
|
||||
|
||||
void savePersonal();
|
||||
|
|
Loading…
Reference in New Issue
Block a user