Create lock file in config folder instead of temp folder

Some linux distros seem to alter TMPDIR environment variable and
therefore hamper qbt ability to find the lock files. So use config
folder instead of TMPDIR folder to create/locate the lock files.
Note that this change will also make qbt become one instance per-user
instead of one instance per-system.

Closes #15646.
This commit is contained in:
Chocobo1 2021-10-30 17:33:58 +08:00
parent 40f2718265
commit a5c531f0a4
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
6 changed files with 29 additions and 70 deletions

View file

@ -154,17 +154,11 @@ Application::Application(int &argc, char **argv)
const QString profileDir = portableModeEnabled
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
: m_commandLineArgs.profileDir;
#ifdef Q_OS_WIN
const QString instanceId = (profileDir + (m_commandLineArgs.configurationName.isEmpty() ? QString {} : ('/' + m_commandLineArgs.configurationName))).toLower();
#else
const QString instanceId = profileDir + (m_commandLineArgs.configurationName.isEmpty() ? QString {} : ('/' + m_commandLineArgs.configurationName));
#endif
const QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString() + '@' + instanceId;
m_instanceManager = new ApplicationInstanceManager {appId, this};
Profile::initInstance(profileDir, m_commandLineArgs.configurationName,
(m_commandLineArgs.relativeFastresumePaths || portableModeEnabled));
m_instanceManager = new ApplicationInstanceManager {Profile::instance()->location(SpecialFolder::Config), this};
Logger::initInstance();
SettingsStorage::initInstance();
Preferences::initInstance();