From 267603e3aa3cf0029411e67ae14018b52344c296 Mon Sep 17 00:00:00 2001 From: Clipperz Date: Tue, 08 Jan 2013 15:17:30 +0000 Subject: Fixed corrupted card problem Changes that check for a weird condition that was causing cards to get corrupted. A similar change has been applied also to /gamma (in a different commit, though) --- (limited to 'frontend') diff --git a/frontend/beta/js/Clipperz/PM/Connection.js b/frontend/beta/js/Clipperz/PM/Connection.js index 85aea21..e81c7a6 100644 --- a/frontend/beta/js/Clipperz/PM/Connection.js +++ b/frontend/beta/js/Clipperz/PM/Connection.js @@ -296,11 +296,15 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log this.setConnectionId(someParameters['connectionId']); this.user().setLoginInfo(someParameters['loginInfo']); this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']); - this.user().setLock(someParameters['lock']); + + if ((isReconnecting == true) && (this.user().lock() != someParameters['lock'])) { + throw Clipperz.PM.Connection.exception.StaleData; + } if (this.oneTimePassword() != null) { result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword())); } + result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn'); result.addCallback(MochiKit.Async.succeed, someParameters); @@ -577,5 +581,6 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. }); Clipperz.PM.Connection.exception = { - WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue") + WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), + StaleData: new MochiKit.Base.NamedError("Stale data") }; diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index ffb45de..ecb6c37 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js @@ -639,11 +639,13 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam 'saveChanges': function() { var result; - if (this.isBrandNew() == false) { - result = this.user().saveRecords([this], 'updateData'); - } else { - result = this.user().saveRecords([this], 'addNewRecords'); - } +// if (this.isBrandNew() == false) { +// result = this.user().saveRecords([this], 'updateData'); +// } else { +// result = this.user().saveRecords([this], 'addNewRecords'); +// } + + result = this.user().saveRecords([this]); return result; }, diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js index dbbe9a0..b065557 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/User.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js @@ -285,14 +285,14 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc //------------------------------------------------------------------------- - 'saveRecords': function(someRecords, aMethodName) { + 'saveRecords': function(someRecords /*, aMethodName*/) { var deferredResult; - var methodName; +// var methodName; var result; var i,c; //console.log("User.saveRecords - someRecords", someRecords); - methodName = aMethodName || 'addNewRecords'; +// methodName = aMethodName || 'addNewRecords'; Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); //MochiKit.Logging.logDebug(">>> User.saveRecords"); @@ -367,7 +367,7 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;}); deferredResult.addCallback(function(aResult, res) { - aResult['records'].push(res); + aResult['records'] = { 'updated': [res] }; return aResult; }, result); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); @@ -376,7 +376,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2"); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); - deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); +// deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName); + deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges'); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;}); for (i=0; i