Merge pull request #15922 from glassez/fix-paths

Correctly concatenate path components
This commit is contained in:
sledgehammer999 2022-01-04 00:17:54 +02:00 committed by GitHub
commit 0a1c61d9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 14 deletions

View File

@ -220,7 +220,7 @@ void Application::setFileLoggerEnabled(const bool value)
QString Application::fileLoggerPath() const
{
return m_storeFileLoggerPath.get(specialFolderLocation(SpecialFolder::Data) + LOG_FOLDER);
return m_storeFileLoggerPath.get(QDir(specialFolderLocation(SpecialFolder::Data)).absoluteFilePath(LOG_FOLDER));
}
void Application::setFileLoggerPath(const QString &path)

View File

@ -74,10 +74,10 @@ namespace
const QString configPath {specialFolderLocation(SpecialFolder::Config)};
migrate(QLatin1String("Preferences/WebUI/HTTPS/Certificate")
, QLatin1String("Preferences/WebUI/HTTPS/CertificatePath")
, Utils::Fs::toNativePath(configPath + QLatin1String("WebUICertificate.crt")));
, Utils::Fs::toNativePath(configPath + QLatin1String("/WebUICertificate.crt")));
migrate(QLatin1String("Preferences/WebUI/HTTPS/Key")
, QLatin1String("Preferences/WebUI/HTTPS/KeyPath")
, Utils::Fs::toNativePath(configPath + QLatin1String("WebUIPrivateKey.pem")));
, Utils::Fs::toNativePath(configPath + QLatin1String("/WebUIPrivateKey.pem")));
}
void upgradeTorrentContentLayout()

View File

@ -4313,7 +4313,7 @@ void Session::startUpTorrents()
qDebug("Initializing torrents resume data storage...");
const QString dbPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + QLatin1String("torrents.db"));
specialFolderLocation(SpecialFolder::Data) + QLatin1String("/torrents.db"));
const bool dbStorageExists = QFile::exists(dbPath);
ResumeDataStorage *startupStorage = nullptr;
@ -4324,14 +4324,14 @@ void Session::startUpTorrents()
if (!dbStorageExists)
{
const QString dataPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + QLatin1String("BT_backup"));
specialFolderLocation(SpecialFolder::Data) + QLatin1String("/BT_backup"));
startupStorage = new BencodeResumeDataStorage(dataPath, this);
}
}
else
{
const QString dataPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + QLatin1String("BT_backup"));
specialFolderLocation(SpecialFolder::Data) + QLatin1String("/BT_backup"));
m_resumeDataStorage = new BencodeResumeDataStorage(dataPath, this);
if (dbStorageExists)

View File

@ -89,7 +89,7 @@ void GeoIPManager::loadDatabase()
m_geoIPDatabase = nullptr;
const QString filepath = Utils::Fs::expandPathAbs(
QString::fromLatin1("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
QString::fromLatin1("%1/%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
QString error;
m_geoIPDatabase = GeoIPDatabase::load(filepath, error);
@ -448,7 +448,7 @@ void GeoIPManager::downloadFinished(const DownloadResult &result)
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
Log::INFO);
const QString targetPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER);
QDir(specialFolderLocation(SpecialFolder::Data)).absoluteFilePath(GEODB_FOLDER));
if (!QDir(targetPath).exists())
QDir().mkpath(targetPath);

View File

@ -88,10 +88,10 @@ QString Private::DefaultProfile::dataLocation() const
#else
// On Linux keep using the legacy directory ~/.local/share/data/ if it exists
const QString legacyDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QLatin1String("/data/") + profileName() + QLatin1Char('/');
+ QLatin1String("/data/") + profileName();
const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QLatin1Char('/') + profileName() + QLatin1Char('/');
+ QLatin1Char('/') + profileName();
if (!QDir(dataDir).exists() && QDir(legacyDir).exists())
{

View File

@ -108,7 +108,7 @@ AutoDownloader::AutoDownloader()
m_instance = this;
m_fileStorage = new AsyncFileStorage(
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Config) + ConfFolderName));
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Config) + QLatin1Char('/') + ConfFolderName));
if (!m_fileStorage)
throw RuntimeError(tr("Directory for RSS AutoDownloader data is unavailable."));

View File

@ -67,7 +67,7 @@ Session::Session()
m_instance = this;
m_confFileStorage = new AsyncFileStorage(
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Config) + ConfFolderName));
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Config) + QLatin1Char('/') + ConfFolderName));
m_confFileStorage->moveToThread(m_workingThread);
connect(m_workingThread, &QThread::finished, m_confFileStorage, &AsyncFileStorage::deleteLater);
connect(m_confFileStorage, &AsyncFileStorage::failed, [](const QString &fileName, const QString &errorString)
@ -77,7 +77,7 @@ Session::Session()
});
m_dataFileStorage = new AsyncFileStorage(
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + DataFolderName));
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + QLatin1Char('/') + DataFolderName));
m_dataFileStorage->moveToThread(m_workingThread);
connect(m_workingThread, &QThread::finished, m_dataFileStorage, &AsyncFileStorage::deleteLater);
connect(m_dataFileStorage, &AsyncFileStorage::failed, [](const QString &fileName, const QString &errorString)

View File

@ -367,7 +367,7 @@ QString SearchPluginManager::engineLocation()
static QString location;
if (location.isEmpty())
{
location = Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + "nova3");
location = Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + "/nova3");
const QDir locationDir(location);
locationDir.mkpath(locationDir.absolutePath());