Allow relative profile paths

PR #19558.
This commit is contained in:
Victor Chernyakin 2023-12-06 23:20:37 -07:00 committed by GitHub
parent 7a41192597
commit 0297f0f34b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -42,6 +42,7 @@
#endif #endif
#include "base/global.h" #include "base/global.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
@ -336,7 +337,7 @@ QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &en
, webUIPort(WEBUI_PORT_OPTION.value(env, -1)) , webUIPort(WEBUI_PORT_OPTION.value(env, -1))
, torrentingPort(TORRENTING_PORT_OPTION.value(env, -1)) , torrentingPort(TORRENTING_PORT_OPTION.value(env, -1))
, skipDialog(SKIP_DIALOG_OPTION.value(env)) , skipDialog(SKIP_DIALOG_OPTION.value(env))
, profileDir(PROFILE_OPTION.value(env)) , profileDir(Utils::Fs::toAbsolutePath(Path(PROFILE_OPTION.value(env))))
, configurationName(CONFIGURATION_OPTION.value(env)) , configurationName(CONFIGURATION_OPTION.value(env))
{ {
addTorrentParams.savePath = Path(SAVE_PATH_OPTION.value(env)); addTorrentParams.savePath = Path(SAVE_PATH_OPTION.value(env));
@ -402,7 +403,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
#endif #endif
else if (arg == PROFILE_OPTION) else if (arg == PROFILE_OPTION)
{ {
result.profileDir = Path(PROFILE_OPTION.value(arg)); result.profileDir = Utils::Fs::toAbsolutePath(Path(PROFILE_OPTION.value(arg)));
} }
else if (arg == RELATIVE_FASTRESUME) else if (arg == RELATIVE_FASTRESUME)
{ {

View file

@ -345,6 +345,11 @@ bool Utils::Fs::isDir(const Path &path)
return QFileInfo(path.data()).isDir(); return QFileInfo(path.data()).isDir();
} }
Path Utils::Fs::toAbsolutePath(const Path &path)
{
return Path(QFileInfo(path.data()).absoluteFilePath());
}
Path Utils::Fs::toCanonicalPath(const Path &path) Path Utils::Fs::toCanonicalPath(const Path &path)
{ {
return Path(QFileInfo(path.data()).canonicalFilePath()); return Path(QFileInfo(path.data()).canonicalFilePath());

View file

@ -55,6 +55,7 @@ namespace Utils::Fs
QString toValidFileName(const QString &name, const QString &pad = u" "_s); QString toValidFileName(const QString &name, const QString &pad = u" "_s);
Path toValidPath(const QString &name, const QString &pad = u" "_s); Path toValidPath(const QString &name, const QString &pad = u" "_s);
Path toAbsolutePath(const Path &path);
Path toCanonicalPath(const Path &path); Path toCanonicalPath(const Path &path);
bool copyFile(const Path &from, const Path &to); bool copyFile(const Path &from, const Path &to);