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 Sep 29, 2022
1 parent 46b2ef6 commit 801a3ce
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 @@ -2148,12 +2148,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 801a3ce

Please sign in to comment.