Skip to content
Snippets Groups Projects
Commit 09911cce authored by echicken's avatar echicken :chicken:
Browse files

Check for stale cache in a way that works for 2.5 and 3.0.

parent 1cb6269c
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
......@@ -31,10 +31,10 @@ OpenWeatherMap.prototype.read_cache = function (endpoint, params) {
const hash = base64_encode(endpoint + JSON.stringify(params));
cache_file = new File(system.temp_dir + 'openweathermap_' + hash + '.json');
if (!cache_file.exists) return;
if (time() - cache_file.date > this.settings.data_refresh) return;
cache_file.open('r');
const cache = JSON.parse(cache_file.read());
cache_file.close();
if (time() - cache.dt > this.settings.data_refresh) return;
return cache;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment