mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-22 21:35:40 +08:00
refs #748, airport JSON reader bug in changed URL fixed (URL was always flagged as changed)
In same step some code cleanup
This commit is contained in:
@@ -55,7 +55,7 @@ namespace BlackCore
|
|||||||
bool CAirportDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
bool CAirportDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getAirportsUrl());
|
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), getBaseUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl CAirportDataReader::getAirportsUrl() const
|
CUrl CAirportDataReader::getAirportsUrl() const
|
||||||
@@ -93,8 +93,9 @@ namespace BlackCore
|
|||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply);
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_airportCache.set(airports, latestTimestamp);
|
this->m_airportCache.set(airports, latestTimestamp);
|
||||||
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, airports.size());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
|
emit this->dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, airports.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::ps_read(CEntityFlags::Entity entity, const QDateTime &newerThan)
|
void CAirportDataReader::ps_read(CEntityFlags::Entity entity, const QDateTime &newerThan)
|
||||||
@@ -131,5 +132,23 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirportDataReader::updateReaderUrl(const CUrl &url)
|
||||||
|
{
|
||||||
|
const CUrl current = this->m_readerUrlCache.get();
|
||||||
|
if (current == url) { return; }
|
||||||
|
const CStatusMessage m = this->m_readerUrlCache.set(url);
|
||||||
|
if (m.isFailure())
|
||||||
|
{
|
||||||
|
CLogMessage::preformatted(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CUrl &CAirportDataReader::getBaseUrl()
|
||||||
|
{
|
||||||
|
static const CUrl baseUrl(sApp->getGlobalSetup().getDbAirportReaderUrl());
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -70,6 +70,13 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Reader URL (we read from where?) used to detect changes of location
|
//! Reader URL (we read from where?) used to detect changes of location
|
||||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::ps_baseUrlCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::ps_baseUrlCacheChanged };
|
||||||
|
|
||||||
|
//! Update reader URL
|
||||||
|
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
||||||
|
|
||||||
|
//! Base URL
|
||||||
|
//! \threadsafe
|
||||||
|
static const BlackMisc::Network::CUrl &getBaseUrl();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->m_aircraftIcaoCache.set(codes, latestTimestamp);
|
this->m_aircraftIcaoCache.set(codes, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
emit dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, n);
|
||||||
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::AircraftIcaoEntity) << urlString;
|
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::AircraftIcaoEntity) << urlString;
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->m_airlineIcaoCache.set(codes, latestTimestamp);
|
this->m_airlineIcaoCache.set(codes, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
emit dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, n);
|
||||||
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::AirlineIcaoEntity) << urlString;
|
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::AirlineIcaoEntity) << urlString;
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->m_countryCache.set(countries, latestTimestamp);
|
this->m_countryCache.set(countries, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
emit dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, n);
|
||||||
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::CountryEntity) << urlString;
|
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::CountryEntity) << urlString;
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,7 @@ namespace BlackCore
|
|||||||
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl());
|
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), getBaseUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl CIcaoDataReader::getAircraftIcaoUrl(bool shared) const
|
CUrl CIcaoDataReader::getAircraftIcaoUrl(bool shared) const
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ namespace BlackCore
|
|||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_liveryCache.set(liveries, latestTimestamp);
|
this->m_liveryCache.set(liveries, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
|
|
||||||
// never emit when lock is held -> deadlock
|
// never emit when lock is held -> deadlock
|
||||||
emit dataRead(CEntityFlags::LiveryEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::LiveryEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
||||||
@@ -325,7 +325,7 @@ namespace BlackCore
|
|||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_distributorCache.set(distributors, latestTimestamp);
|
this->m_distributorCache.set(distributors, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
|
|
||||||
emit dataRead(CEntityFlags::DistributorEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::DistributorEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
||||||
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::DistributorEntity) << urlString;
|
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::DistributorEntity) << urlString;
|
||||||
@@ -368,7 +368,7 @@ namespace BlackCore
|
|||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_modelCache.set(models, latestTimestamp);
|
this->m_modelCache.set(models, latestTimestamp);
|
||||||
this->updateReaderUrl(this->getBaseUrl());
|
this->updateReaderUrl(getBaseUrl());
|
||||||
|
|
||||||
emit dataRead(CEntityFlags::ModelEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
emit dataRead(CEntityFlags::ModelEntity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, n);
|
||||||
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::ModelEntity) << urlString;
|
CLogMessage(this).info("Read %1 %2 from %3") << n << CEntityFlags::flagToString(CEntityFlags::ModelEntity) << urlString;
|
||||||
@@ -505,7 +505,7 @@ namespace BlackCore
|
|||||||
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl());
|
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), getBaseUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
const CUrl &CModelDataReader::getBaseUrl()
|
const CUrl &CModelDataReader::getBaseUrl()
|
||||||
|
|||||||
Reference in New Issue
Block a user