Remove old app ids from updatechecker state

Fixes #472
This commit is contained in:
Girish Ramakrishnan
2015-09-22 22:46:14 -07:00
parent ded5d4c98b
commit 2a39526a4c
+6 -4
View File
@@ -125,7 +125,8 @@ function getBoxUpdates(callback) {
function checkAppUpdates() { function checkAppUpdates() {
debug('Checking App Updates'); debug('Checking App Updates');
var state = loadState(); var oldState = loadState();
var newState = { box: oldState.box }; // creaee new state so that old app ids are removed
getAppUpdates(function (error, result) { getAppUpdates(function (error, result) {
if (error) debug('Error checking app updates: ', error); if (error) debug('Error checking app updates: ', error);
@@ -133,7 +134,9 @@ function checkAppUpdates() {
gAppUpdateInfo = error ? {} : result; gAppUpdateInfo = error ? {} : result;
async.eachSeries(Object.keys(gAppUpdateInfo), function iterator(id, iteratorDone) { async.eachSeries(Object.keys(gAppUpdateInfo), function iterator(id, iteratorDone) {
if (state[id] === gAppUpdateInfo[id].manifest.version) { newState[id] = gAppUpdateInfo[id].manifest.version;
if (oldState[id] === gAppUpdateInfo[id].manifest.version) {
debug('Skipping notification of app update %s since user was already notified', id); debug('Skipping notification of app update %s since user was already notified', id);
return iteratorDone(); return iteratorDone();
} }
@@ -145,11 +148,10 @@ function checkAppUpdates() {
} }
mailer.appUpdateAvailable(app, gAppUpdateInfo[id]); mailer.appUpdateAvailable(app, gAppUpdateInfo[id]);
state[id] = gAppUpdateInfo[id].manifest.version;
iteratorDone(); iteratorDone();
}); });
}, function () { }, function () {
saveState(state); saveState(newState);
}); });
}); });
} }