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