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)
This commit is contained in:
Clipperz 2013-01-08 16:17:30 +01:00
parent b6a11a37ec
commit 267603e3aa
3 changed files with 24 additions and 14 deletions

View File

@ -296,11 +296,15 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log
this.setConnectionId(someParameters['connectionId']); this.setConnectionId(someParameters['connectionId']);
this.user().setLoginInfo(someParameters['loginInfo']); this.user().setLoginInfo(someParameters['loginInfo']);
this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']); 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) { if (this.oneTimePassword() != null) {
result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword())); result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword()));
} }
result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn'); result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn');
result.addCallback(MochiKit.Async.succeed, someParameters); 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 = { 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")
}; };

View File

@ -639,11 +639,13 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam
'saveChanges': function() { 'saveChanges': function() {
var result; var result;
if (this.isBrandNew() == false) { // if (this.isBrandNew() == false) {
result = this.user().saveRecords([this], 'updateData'); // result = this.user().saveRecords([this], 'updateData');
} else { // } else {
result = this.user().saveRecords([this], 'addNewRecords'); // result = this.user().saveRecords([this], 'addNewRecords');
} // }
result = this.user().saveRecords([this]);
return result; return result;
}, },

View File

@ -285,14 +285,14 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
'saveRecords': function(someRecords, aMethodName) { 'saveRecords': function(someRecords /*, aMethodName*/) {
var deferredResult; var deferredResult;
var methodName; // var methodName;
var result; var result;
var i,c; var i,c;
//console.log("User.saveRecords - someRecords", someRecords); //console.log("User.saveRecords - someRecords", someRecords);
methodName = aMethodName || 'addNewRecords'; // methodName = aMethodName || 'addNewRecords';
Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true); Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true);
//MochiKit.Logging.logDebug(">>> User.saveRecords"); //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.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;});
deferredResult.addCallback(function(aResult, res) { deferredResult.addCallback(function(aResult, res) {
aResult['records'].push(res); aResult['records'] = { 'updated': [res] };
return aResult; return aResult;
}, result); }, result);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;}); //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.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData'); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;}); //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;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;});
for (i=0; i<c; i++) { for (i=0; i<c; i++) {
@ -431,7 +432,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
return result; return result;
}, someRecords); }, someRecords);
someParameters.recordReferences = recordReferences; // someParameters.recordReferences = recordReferences;
someParameters['records'] = { 'deleted': recordReferences};
return someParameters; return someParameters;
}, parameters); }, parameters);
@ -448,7 +450,8 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData'); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;});
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords'); // deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords');
deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface'); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;}); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;});