mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 493816 - Timestamps need to be saved as string prefs
Internally store .lastSync as a string but keep exposing set/getters as float values. parseFloat takes both strings and numbers and gives a number. --HG-- extra : rebase_source : b657dd3f732b9f3b3b0ef208ee53e799aa87d2c6
This commit is contained in:
parent
e4a8c23658
commit
ce951c538a
@ -249,18 +249,18 @@ SyncEngine.prototype = {
|
||||
},
|
||||
|
||||
get lastSync() {
|
||||
return Svc.Prefs.get(this.name + ".lastSync", 0);
|
||||
return parseFloat(Svc.Prefs.get(this.name + ".lastSync", "0"));
|
||||
},
|
||||
set lastSync(value) {
|
||||
// Reset the pref in-case it's a number instead of a string
|
||||
Svc.Prefs.reset(this.name + ".lastSync");
|
||||
if (typeof(value) == "string")
|
||||
value = parseInt(value);
|
||||
Svc.Prefs.set(this.name + ".lastSync", value);
|
||||
// Store the value as a string to keep floating point precision
|
||||
Svc.Prefs.set(this.name + ".lastSync", value.toString());
|
||||
},
|
||||
resetLastSync: function SyncEngine_resetLastSync() {
|
||||
this._log.debug("Resetting " + this.name + " last sync time");
|
||||
Svc.Prefs.reset(this.name + ".lastSync");
|
||||
Svc.Prefs.set(this.name + ".lastSync", 0);
|
||||
Svc.Prefs.set(this.name + ".lastSync", "0");
|
||||
},
|
||||
|
||||
// Create a new record by querying the store, and add the engine metadata
|
||||
|
8
services/sync/tests/unit/test_engine_lastSync.js
Normal file
8
services/sync/tests/unit/test_engine_lastSync.js
Normal file
@ -0,0 +1,8 @@
|
||||
Cu.import("resource://weave/engines.js");
|
||||
|
||||
function run_test() {
|
||||
// Make sure storing floats for lastSync stay as floats
|
||||
let engine = new SyncEngine();
|
||||
engine.lastSync = 123.45;
|
||||
do_check_eq(engine.lastSync, 123.45);
|
||||
}
|
Loading…
Reference in New Issue
Block a user