Fixed a bug that would "corrupt" header data when upgrading the crypto version used to process an account data

The problem being that only part of the header section would be re-encrypted, thus ending up with different sections encrypted using different crypto function versions.
And this would break when loading data back on next login.
This commit is contained in:
Giulio Cesare Solaroli 2013-04-26 11:18:23 +02:00
parent 65f064cb6c
commit 108dd23db8

View File

@ -81,7 +81,8 @@ Clipperz.PM.DataModel.Header.prototype = MochiKit.Base.update(null, {
},
'hasSectionBeenUpdated': function(aSectionName) {
return (this.updatedSections().join().indexOf(aSectionName) != -1);
return (this.updatedSections().join().indexOf(aSectionName) != -1)
|| (this.serverDataVersion() != Clipperz.PM.Crypto.encryptingFunctions.currentVersion);
},
'cachedServerDataSection': function(aSectionName) {
@ -412,6 +413,7 @@ Clipperz.PM.DataModel.Header.prototype = MochiKit.Base.update(null, {
//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_decryptingUserData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Header.extractDataWithKey 5: "/* + res*/); return res;});
//deferredResult.addBoth(function(res) {console.log("aKey: " + aKey); return res;});
//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;});
deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.user().passphrase(), data[aKey]['data'], this.serverDataVersion());
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Header.extractDataWithKey 6: "/* + res*/); return res;});