Commit 659fec71 authored by Volker Krause's avatar Volker Krause

Check if the local cache is new enough before fetching new weather tiles

parent e478041c
...@@ -382,7 +382,7 @@ void TimelineModel::insertWeatherElements() ...@@ -382,7 +382,7 @@ void TimelineModel::insertWeatherElements()
} }
// TODO determine correct location, merge full time range // TODO determine correct location, merge full time range
// m_weatherMgr->monitorLocation(52, 13.5); m_weatherMgr->monitorLocation(52, 13.5);
const auto fc = m_weatherMgr->forecast(52, 13.5, QDateTime(date, QTime(12, 0))); const auto fc = m_weatherMgr->forecast(52, 13.5, QDateTime(date, QTime(12, 0)));
if (!fc.isValid()) { if (!fc.isValid()) {
date = date.addDays(1); date = date.addDays(1);
......
...@@ -89,6 +89,11 @@ QVariant WeatherForecastManager::forecast(float latitude, float longitude, const ...@@ -89,6 +89,11 @@ QVariant WeatherForecastManager::forecast(float latitude, float longitude, const
void WeatherForecastManager::fetchTile(WeatherTile tile) void WeatherForecastManager::fetchTile(WeatherTile tile)
{ {
QFileInfo fi(cachePath(tile) + QLatin1String("forecast.xml"));
if (fi.exists() && fi.lastModified().toUTC().addSecs(3600 * 2) >= QDateTime::currentDateTimeUtc()) { // cache is already new enough
return;
}
m_pendingTiles.push_back(tile); m_pendingTiles.push_back(tile);
fetchNext(); fetchNext();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment