Prevent exceptions if weather.json doesn't exist.

pull/2561/head
Sam Sorensen 2023-02-05 20:18:37 -07:00
parent f4f07806a6
commit 5c3b742a42
1 changed files with 7 additions and 2 deletions

View File

@ -324,8 +324,13 @@ function setWeather() {
} }
function readWeather() { function readWeather() {
data = require("Storage").readJSON('weather.json').weather; var weatherData = require("Storage").readJSON('weather.json', true);
if (weatherData !== undefined) {
if (weatherData.weather.time > data.time) {
data = weatherData.weather;
require("Storage").write('mtnclock.json', data); require("Storage").write('mtnclock.json', data);
}
}
} }
const _GB = global.GB; const _GB = global.GB;