mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-26 22:44:36 +00:00
Enable portable mode if "profile" directory exists
Enable portable mode if "profile" directory exists in the app dir. Remove "--portable" command line argument. Add logging of current profile config directory. Closes #9445.
This commit is contained in:
parent
0b91c4d890
commit
053ee48692
@ -144,13 +144,13 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||||||
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
|
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
validateCommandLineParameters();
|
const bool portableModeEnabled = m_commandLineArgs.profileDir.isEmpty() && QDir(QCoreApplication::applicationDirPath()).exists(DEFAULT_PORTABLE_MODE_PROFILE_DIR);
|
||||||
|
|
||||||
const QString profileDir = m_commandLineArgs.portableMode
|
const QString profileDir = portableModeEnabled
|
||||||
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
|
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
|
||||||
: m_commandLineArgs.profileDir;
|
: m_commandLineArgs.profileDir;
|
||||||
Profile::initialize(profileDir, m_commandLineArgs.configurationName,
|
Profile::initialize(profileDir, m_commandLineArgs.configurationName,
|
||||||
m_commandLineArgs.relativeFastresumePaths || m_commandLineArgs.portableMode);
|
(m_commandLineArgs.relativeFastresumePaths || portableModeEnabled));
|
||||||
|
|
||||||
Logger::initInstance();
|
Logger::initInstance();
|
||||||
SettingsStorage::initInstance();
|
SettingsStorage::initInstance();
|
||||||
@ -171,6 +171,14 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||||||
m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));
|
m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));
|
||||||
|
|
||||||
Logger::instance()->addMessage(tr("qBittorrent %1 started", "qBittorrent v3.2.0alpha started").arg(QBT_VERSION));
|
Logger::instance()->addMessage(tr("qBittorrent %1 started", "qBittorrent v3.2.0alpha started").arg(QBT_VERSION));
|
||||||
|
if (portableModeEnabled) {
|
||||||
|
Logger::instance()->addMessage(tr("Running in portable mode. Auto detected profile folder at: %1").arg(profileDir));
|
||||||
|
if (m_commandLineArgs.relativeFastresumePaths)
|
||||||
|
Logger::instance()->addMessage(tr("Redundant command line flag detected: \"%1\". Portable mode implies relative fastresume.").arg("--relative-fastresume"), Log::WARNING); // to avoid translating the `--relative-fastresume` string
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Logger::instance()->addMessage(tr("Using config directory: %1").arg(Profile::instance().location(SpecialFolder::Config)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
@ -737,12 +745,3 @@ void Application::cleanup()
|
|||||||
Utils::Misc::shutdownComputer(m_shutdownAct);
|
Utils::Misc::shutdownComputer(m_shutdownAct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::validateCommandLineParameters()
|
|
||||||
{
|
|
||||||
if (m_commandLineArgs.portableMode && !m_commandLineArgs.profileDir.isEmpty())
|
|
||||||
throw CommandLineParameterError(tr("Portable mode and explicit profile directory options are mutually exclusive"));
|
|
||||||
|
|
||||||
if (m_commandLineArgs.portableMode && m_commandLineArgs.relativeFastresumePaths)
|
|
||||||
Logger::instance()->addMessage(tr("Portable mode implies relative fastresume"), Log::WARNING);
|
|
||||||
}
|
|
||||||
|
@ -144,5 +144,4 @@ private:
|
|||||||
void processParams(const QStringList ¶ms);
|
void processParams(const QStringList ¶ms);
|
||||||
void runExternalProgram(const BitTorrent::TorrentHandle *torrent) const;
|
void runExternalProgram(const BitTorrent::TorrentHandle *torrent) const;
|
||||||
void sendNotificationEmail(const BitTorrent::TorrentHandle *torrent);
|
void sendNotificationEmail(const BitTorrent::TorrentHandle *torrent);
|
||||||
void validateCommandLineParameters();
|
|
||||||
};
|
};
|
||||||
|
@ -318,7 +318,6 @@ namespace
|
|||||||
constexpr const IntOption WEBUI_PORT_OPTION {"webui-port"};
|
constexpr const IntOption WEBUI_PORT_OPTION {"webui-port"};
|
||||||
constexpr const StringOption PROFILE_OPTION {"profile"};
|
constexpr const StringOption PROFILE_OPTION {"profile"};
|
||||||
constexpr const StringOption CONFIGURATION_OPTION {"configuration"};
|
constexpr const StringOption CONFIGURATION_OPTION {"configuration"};
|
||||||
constexpr const BoolOption PORTABLE_OPTION {"portable"};
|
|
||||||
constexpr const BoolOption RELATIVE_FASTRESUME {"relative-fastresume"};
|
constexpr const BoolOption RELATIVE_FASTRESUME {"relative-fastresume"};
|
||||||
constexpr const StringOption SAVE_PATH_OPTION {"save-path"};
|
constexpr const StringOption SAVE_PATH_OPTION {"save-path"};
|
||||||
constexpr const TriStateBoolOption PAUSED_OPTION {"add-paused", true};
|
constexpr const TriStateBoolOption PAUSED_OPTION {"add-paused", true};
|
||||||
@ -332,7 +331,6 @@ namespace
|
|||||||
QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &env)
|
QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &env)
|
||||||
: showHelp(false)
|
: showHelp(false)
|
||||||
, relativeFastresumePaths(RELATIVE_FASTRESUME.value(env))
|
, relativeFastresumePaths(RELATIVE_FASTRESUME.value(env))
|
||||||
, portableMode(PORTABLE_OPTION.value(env))
|
|
||||||
, skipChecking(SKIP_HASH_CHECK_OPTION.value(env))
|
, skipChecking(SKIP_HASH_CHECK_OPTION.value(env))
|
||||||
, sequential(SEQUENTIAL_OPTION.value(env))
|
, sequential(SEQUENTIAL_OPTION.value(env))
|
||||||
, firstLastPiecePriority(FIRST_AND_LAST_OPTION.value(env))
|
, firstLastPiecePriority(FIRST_AND_LAST_OPTION.value(env))
|
||||||
@ -437,9 +435,6 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
|
|||||||
else if (arg == RELATIVE_FASTRESUME) {
|
else if (arg == RELATIVE_FASTRESUME) {
|
||||||
result.relativeFastresumePaths = true;
|
result.relativeFastresumePaths = true;
|
||||||
}
|
}
|
||||||
else if (arg == PORTABLE_OPTION) {
|
|
||||||
result.portableMode = true;
|
|
||||||
}
|
|
||||||
else if (arg == CONFIGURATION_OPTION) {
|
else if (arg == CONFIGURATION_OPTION) {
|
||||||
result.configurationName = CONFIGURATION_OPTION.value(arg);
|
result.configurationName = CONFIGURATION_OPTION.value(arg);
|
||||||
}
|
}
|
||||||
@ -544,9 +539,6 @@ QString makeUsage(const QString &prgName)
|
|||||||
stream << RELATIVE_FASTRESUME.usage()
|
stream << RELATIVE_FASTRESUME.usage()
|
||||||
<< wrapText(QObject::tr("Hack into libtorrent fastresume files and make file paths relative "
|
<< wrapText(QObject::tr("Hack into libtorrent fastresume files and make file paths relative "
|
||||||
"to the profile directory")) << '\n';
|
"to the profile directory")) << '\n';
|
||||||
stream << PORTABLE_OPTION.usage()
|
|
||||||
<< wrapText(QObject::tr("Shortcut for %1", "Shortcut for --profile=<exe dir>/profile --relative-fastresume")
|
|
||||||
.arg(QLatin1String("--profile=<exe dir>/profile --relative-fastresume"))) << '\n';
|
|
||||||
stream << Option::padUsageText(QObject::tr("files or URLs"))
|
stream << Option::padUsageText(QObject::tr("files or URLs"))
|
||||||
<< wrapText(QObject::tr("Download the torrents passed by the user")) << '\n'
|
<< wrapText(QObject::tr("Download the torrents passed by the user")) << '\n'
|
||||||
<< '\n';
|
<< '\n';
|
||||||
|
@ -42,7 +42,7 @@ class QProcessEnvironment;
|
|||||||
|
|
||||||
struct QBtCommandLineParameters
|
struct QBtCommandLineParameters
|
||||||
{
|
{
|
||||||
bool showHelp, relativeFastresumePaths, portableMode, skipChecking, sequential, firstLastPiecePriority;
|
bool showHelp, relativeFastresumePaths, skipChecking, sequential, firstLastPiecePriority;
|
||||||
#if !defined(Q_OS_WIN) || defined(DISABLE_GUI)
|
#if !defined(Q_OS_WIN) || defined(DISABLE_GUI)
|
||||||
bool showVersion;
|
bool showVersion;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user