Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit e5324c9

Browse files
authored
Merge pull request #2055 from RocketChat/fix/clean-invalid-databases
[BUG] Sometimes the user keeps looping to connect into the server (Realm becomes inconsistent
2 parents a3d313d + 6f8f05a commit e5324c9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Rocket.Chat/Managers/DatabaseManager.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ struct DatabaseManager {
115115
let servers = self.servers ?? []
116116
var validServers: [[String: String]] = []
117117

118-
for server in servers {
118+
for (index, server) in servers.enumerated() {
119119
guard
120120
server[ServerPersistKeys.token] != nil,
121121
server[ServerPersistKeys.userId] != nil,
122122
server[ServerPersistKeys.databaseName] != nil,
123-
server[ServerPersistKeys.serverURL] != nil
123+
server[ServerPersistKeys.serverURL] != nil,
124+
let realmConfiguration = databaseConfiguration(index: index),
125+
(try? Realm(configuration: realmConfiguration)) != nil
124126
else {
125127
continue
126128
}

0 commit comments

Comments
 (0)