mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refactor: Simplify getting shared data directory URL
This commit is contained in:
@@ -97,25 +97,9 @@ namespace BlackCore::Data
|
||||
m_dbDebugFlag = debug;
|
||||
}
|
||||
|
||||
CUrl CGlobalSetup::buildDbDataDirectoryUrl(const CUrl &candidate)
|
||||
CUrl CGlobalSetup::getSharedDbDataDirectoryUrl()
|
||||
{
|
||||
if (candidate.isEmpty()) return CUrl(); // not possible
|
||||
static const QString version(QString(schemaVersionString()).append("/"));
|
||||
if (candidate.pathEndsWith("dbdata") || candidate.pathEndsWith("dbdata/")) { return candidate; }
|
||||
CUrl url(candidate);
|
||||
if (candidate.pathEndsWith(schemaVersionString()) || candidate.pathEndsWith(version))
|
||||
{
|
||||
url.appendPath("/dbdata");
|
||||
}
|
||||
else if (candidate.pathEndsWith("shared") || candidate.pathEndsWith("shared/"))
|
||||
{
|
||||
url.appendPath(CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||
}
|
||||
else
|
||||
{
|
||||
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||
}
|
||||
return url;
|
||||
return m_sharedUrl.withAppendedPath(CGlobalSetup::schemaVersionString() + "/dbdata/");
|
||||
}
|
||||
|
||||
CServerList CGlobalSetup::getPredefinedServersPlusHardcodedServers() const
|
||||
|
||||
@@ -152,6 +152,9 @@ namespace BlackCore::Data
|
||||
//! To string with separator
|
||||
QString convertToQString(const QString &separator, bool i18n = false) const;
|
||||
|
||||
//! Get shared DB data directory URL
|
||||
BlackMisc::Network::CUrl getSharedDbDataDirectoryUrl();
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
|
||||
|
||||
@@ -161,9 +164,6 @@ namespace BlackCore::Data
|
||||
//! Schema version (shared files, bootstrap file)
|
||||
static const QString &schemaVersionString();
|
||||
|
||||
//! Build the full dbdata directory URL from shared URL
|
||||
static BlackMisc::Network::CUrl buildDbDataDirectoryUrl(const BlackMisc::Network::CUrl &candidate);
|
||||
|
||||
private:
|
||||
int m_dbHttpPort = 80; //!< port
|
||||
int m_dbHttpsPort = 443; //!< SSL port
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace BlackCore::Db
|
||||
return this->getDbServiceBaseUrl().withAppendedPath("/service");
|
||||
case CDbFlags::SharedInfoOnly:
|
||||
case CDbFlags::Shared:
|
||||
return CDatabaseReader::getSharedDbdataDirectoryUrl();
|
||||
return sApp->getGlobalSetup().getSharedDbDataDirectoryUrl();
|
||||
default:
|
||||
qFatal("Wrong mode");
|
||||
break;
|
||||
@@ -693,13 +693,6 @@ namespace BlackCore::Db
|
||||
return dbUrl;
|
||||
}
|
||||
|
||||
CUrl CDatabaseReader::getSharedDbdataDirectoryUrl()
|
||||
{
|
||||
const CUrlList sharedUrls = sApp->getGlobalSetup().getSwiftSharedUrls();
|
||||
Q_ASSERT_X(!sharedUrls.empty(), Q_FUNC_INFO, "Need at least one shared URL");
|
||||
return CGlobalSetup::buildDbDataDirectoryUrl(sharedUrls[0]);
|
||||
}
|
||||
|
||||
void CDatabaseReader::cacheHasChanged(CEntityFlags::Entity entities)
|
||||
{
|
||||
this->emitReadSignalPerSingleCachedEntity(entities, false);
|
||||
|
||||
@@ -343,9 +343,6 @@ namespace BlackCore::Db
|
||||
//! DB base URL
|
||||
static const BlackMisc::Network::CUrl &getDbUrl();
|
||||
|
||||
//! shared "dbdata" directory URL
|
||||
static BlackMisc::Network::CUrl getSharedDbdataDirectoryUrl();
|
||||
|
||||
//! File name for given mode, either php service or shared file name
|
||||
static QString fileNameForMode(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user