Skip to content

Commit

Permalink
Fix migration from schema <= 12 to schema > 16. Issue matrix-org#1282
Browse files Browse the repository at this point in the history
Signed-off-by: N-Pex <[email protected]>
  • Loading branch information
N-Pex committed Nov 30, 2021
1 parent dfd1f77 commit ecd1e00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2143,12 +2143,15 @@ + (BOOL)finaliseMigrationWith:(RLMMigration *)migration oldSchemaVersion:(uint64

MXLogDebug(@"[MXRealmCryptoStore] Make sure MXRealmOlmAccount.cryptoVersion is MXCryptoVersion2");
[migration enumerateObjects:MXRealmOlmAccount.className block:^(RLMObject *oldObject, RLMObject *newObject) {
NSNumber *version;
MXJSONModelSetNumber(version, oldObject[@"cryptoVersion"]);
if (version && version.intValue == 0)
{
MXLogDebug(@"[MXRealmCryptoStore] -> Fix MXRealmOlmAccount.cryptoVersion");
newObject[@"cryptoVersion"] = @(MXCryptoVersion2);
if (oldSchemaVersion > 12) {
// cryptoVersion available
NSNumber *version;
MXJSONModelSetNumber(version, oldObject[@"cryptoVersion"]);
if (version && version.intValue == 0)
{
MXLogDebug(@"[MXRealmCryptoStore] -> Fix MXRealmOlmAccount.cryptoVersion");
newObject[@"cryptoVersion"] = @(MXCryptoVersion2);
}
}
}];
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1282.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MXRealmCryptoStore: fix migration from schema < 13 to schema > 16.

0 comments on commit ecd1e00

Please sign in to comment.