ndb: add safemode so we don't instantly crash on bad dbs

Fixes: https://github.com/damus-io/damus/issues/1741
This commit is contained in:
William Casarin
2023-12-04 12:42:45 -08:00
parent 4e447ddbed
commit a07b78e47f
6 changed files with 42 additions and 14 deletions
+14 -1
View File
@@ -602,7 +602,20 @@ struct ContentView: View {
func connect() {
// nostrdb
let ndb = try! Ndb()!
var mndb = Ndb()
if mndb == nil {
// try recovery
print("DB ISSUE! RECOVERING")
mndb = Ndb.safemode()
// out of space or something?? maybe we need a in-memory fallback
if mndb == nil {
notify(.logout)
return
}
}
guard let ndb = mndb else { return }
let pool = RelayPool(ndb: ndb)
let model_cache = RelayModelCache()