✏️ Check if state is changed before saving it

This commit is contained in:
Sebclem 2021-01-11 00:01:02 +01:00
parent 61ddd73a8c
commit ee25207856

View File

@ -29,7 +29,15 @@ function getStatus() {
} }
function setStatus(state) { function setStatus(state) {
if (fs.existsSync(statusPath)) {
let old_state_str = fs.readFileSync(statusPath).toString();
if(old_state_str !== JSON.stringify(state)){
fs.writeFileSync(statusPath, JSON.stringify(state)); fs.writeFileSync(statusPath, JSON.stringify(state));
}
}else{
fs.writeFileSync(statusPath, JSON.stringify(state));
}
} }
exports.init = init; exports.init = init;