From 2a39526a4cc75f6fb5279eb4e6a6c881bc3a9ab3 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 22 Sep 2015 22:46:14 -0700 Subject: [PATCH] Remove old app ids from updatechecker state Fixes #472 --- src/updatechecker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/updatechecker.js b/src/updatechecker.js index 7910d06e2..f4330ad15 100644 --- a/src/updatechecker.js +++ b/src/updatechecker.js @@ -125,7 +125,8 @@ function getBoxUpdates(callback) { function checkAppUpdates() { 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) { if (error) debug('Error checking app updates: ', error); @@ -133,7 +134,9 @@ function checkAppUpdates() { gAppUpdateInfo = error ? {} : result; 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); return iteratorDone(); } @@ -145,11 +148,10 @@ function checkAppUpdates() { } mailer.appUpdateAvailable(app, gAppUpdateInfo[id]); - state[id] = gAppUpdateInfo[id].manifest.version; iteratorDone(); }); }, function () { - saveState(state); + saveState(newState); }); }); }