Avoid writing unchanged settings

This commit is contained in:
Nick O'Leary 2014-10-03 14:47:23 +01:00
parent 86d4179039
commit c223e7f58f
1 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,8 @@
var when = require("when");
var assert = require("assert");
var userSettings = null;
var globalSettings = null;
var storage = null;
@ -59,7 +61,13 @@ var persistentSettings = {
throw new Error("Settings not available");
}
globalSettings[prop] = value;
return storage.saveSettings(globalSettings);
var current = persistentSettings.get(prop);
try {
assert.deepEqual(current,value);
return when.resolve();
} catch(err) {
return storage.saveSettings(globalSettings);
}
},
available: function() {