mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
refactor: Directly use shared URL from global setup
Previous we relyed on the watchdog providing a working shared URL (or empty URL if no URL was reachable). This creates some overhead and might not work in all cases because of the time between the call to getWorkingSharedUrl() and the actual network request. Further, not all calls that are fetching data from our servers were using the shared URL from the watchdog anyway. Lastly, this careful checking if the URL is available is only done for the shared URL and not for all the other URLs that are queried by swift.
This commit is contained in:
@@ -385,7 +385,7 @@ namespace BlackCore::Db
|
||||
|
||||
CEntityFlags::Entity allEntities = entities & CEntityFlags::AllDbEntitiesNoInfoObjects;
|
||||
CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(allEntities);
|
||||
const CUrl urlSharedDbdata = CDatabaseReader::getWorkingSharedDbdataDirectoryUrl();
|
||||
const CUrl urlSharedDbdata = CDatabaseReader::getSharedDbdataDirectoryUrl();
|
||||
if (urlSharedDbdata.isEmpty())
|
||||
{
|
||||
CLogMessage(this).warning(u"No working shared URL, cannot request headers");
|
||||
@@ -510,7 +510,7 @@ namespace BlackCore::Db
|
||||
return this->getDbServiceBaseUrl().withAppendedPath("/service");
|
||||
case CDbFlags::SharedInfoOnly:
|
||||
case CDbFlags::Shared:
|
||||
return CDatabaseReader::getWorkingSharedDbdataDirectoryUrl();
|
||||
return CDatabaseReader::getSharedDbdataDirectoryUrl();
|
||||
default:
|
||||
qFatal("Wrong mode");
|
||||
break;
|
||||
@@ -731,10 +731,11 @@ namespace BlackCore::Db
|
||||
return dbUrl;
|
||||
}
|
||||
|
||||
CUrl CDatabaseReader::getWorkingSharedDbdataDirectoryUrl()
|
||||
CUrl CDatabaseReader::getSharedDbdataDirectoryUrl()
|
||||
{
|
||||
const CUrl sharedUrl(sApp->getWorkingSharedUrl());
|
||||
return CGlobalSetup::buildDbDataDirectoryUrl(sharedUrl);
|
||||
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)
|
||||
|
||||
@@ -347,8 +347,8 @@ namespace BlackCore::Db
|
||||
//! DB base URL
|
||||
static const BlackMisc::Network::CUrl &getDbUrl();
|
||||
|
||||
//! Working shared "dbdata" directory URL
|
||||
static BlackMisc::Network::CUrl getWorkingSharedDbdataDirectoryUrl();
|
||||
//! 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