mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 13:48:05 -06:00
Save relative paths in fastresume files
Conditionally change absolute paths to relative in the fastresume data files. The condition is specified by user via a command line parameter and paths are relative to the profile dir. On Windows the convertion to relative path is performed if the path and the profile are on the same drive only.
This commit is contained in:
@@ -111,7 +111,8 @@ Application::Application(const QString &id, int &argc, char **argv)
|
||||
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
|
||||
: m_commandLineArgs.profileDir;
|
||||
|
||||
Profile::initialize(profileDir, m_commandLineArgs.configurationName);
|
||||
Profile::initialize(profileDir, m_commandLineArgs.configurationName,
|
||||
m_commandLineArgs.relativeFastresumePaths || m_commandLineArgs.portableMode);
|
||||
|
||||
Logger::initInstance();
|
||||
SettingsStorage::initInstance();
|
||||
@@ -660,4 +661,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace
|
||||
constexpr const StringOption PROFILE_OPTION = {"profile"};
|
||||
constexpr const StringOption CONFIGURATION_OPTION = {"configuration"};
|
||||
constexpr const BoolOption PORTABLE_OPTION = {"portable"};
|
||||
constexpr const BoolOption RELATIVE_FASTRESUME = {"relative-fastresume"};
|
||||
}
|
||||
|
||||
QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &env)
|
||||
@@ -260,6 +261,7 @@ QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &en
|
||||
#endif
|
||||
, webUiPort(WEBUI_PORT_OPTION.value(env, -1))
|
||||
, profileDir(PROFILE_OPTION.value(env))
|
||||
, relativeFastresumePaths(RELATIVE_FASTRESUME.value(env))
|
||||
, portableMode(PORTABLE_OPTION.value(env))
|
||||
, configurationName(CONFIGURATION_OPTION.value(env))
|
||||
{
|
||||
@@ -301,6 +303,9 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
|
||||
else if (arg == PROFILE_OPTION) {
|
||||
result.profileDir = PROFILE_OPTION.value(arg);
|
||||
}
|
||||
else if (arg == RELATIVE_FASTRESUME) {
|
||||
result.relativeFastresumePaths = true;
|
||||
}
|
||||
else if (arg == PORTABLE_OPTION) {
|
||||
result.portableMode = true;
|
||||
}
|
||||
@@ -362,9 +367,9 @@ QString makeUsage(const QString &prgName)
|
||||
stream << DAEMON_OPTION.usage() << QObject::tr("Run in daemon-mode (background)") << '\n';
|
||||
#endif
|
||||
stream << PROFILE_OPTION.usage(QLatin1String("dir")) << QObject::tr("Store configuration files in <dir>") << '\n';
|
||||
stream << PORTABLE_OPTION.usage() << QObject::tr("Shortcut for --profile=<exe dir>/profile") << '\n';
|
||||
stream << CONFIGURATION_OPTION.usage(QLatin1String("name")) << QObject::tr("Store configuration files in directories qBittorrent_<name>")
|
||||
<< '\n';
|
||||
stream << CONFIGURATION_OPTION.usage(QLatin1String("name")) << QObject::tr("Store configuration files in directories qBittorrent_<name>") << '\n';
|
||||
stream << RELATIVE_FASTRESUME.usage() << QObject::tr("Hack into libtorrent fastresume files and make file paths relative to the profile directory") << '\n';
|
||||
stream << PORTABLE_OPTION.usage() << QObject::tr("Shortcut for --profile=<exe dir>/profile --relative-fastresume") << '\n';
|
||||
stream << "\tfiles or urls\t\t" << QObject::tr("Downloads the torrents passed by the user") << '\n'
|
||||
<< '\n';
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ struct QBtCommandLineParameters
|
||||
#endif
|
||||
int webUiPort;
|
||||
QString profileDir;
|
||||
bool relativeFastresumePaths;
|
||||
bool portableMode;
|
||||
QString configurationName;
|
||||
QStringList torrents;
|
||||
|
||||
Reference in New Issue
Block a user