mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07: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
4 changed files with 12 additions and 22 deletions
|
@ -144,13 +144,13 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
|
||||
#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)
|
||||
: m_commandLineArgs.profileDir;
|
||||
Profile::initialize(profileDir, m_commandLineArgs.configurationName,
|
||||
m_commandLineArgs.relativeFastresumePaths || m_commandLineArgs.portableMode);
|
||||
(m_commandLineArgs.relativeFastresumePaths || portableModeEnabled));
|
||||
|
||||
Logger::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()));
|
||||
|
||||
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()
|
||||
|
@ -737,12 +745,3 @@ void Application::cleanup()
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue