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:
@@ -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()
|
||||
|
||||
@@ -64,7 +64,7 @@ var test_damus_state: DamusState = ({
|
||||
}
|
||||
|
||||
print("opening \(tempDir!)")
|
||||
let ndb = try! Ndb(path: tempDir)!
|
||||
let ndb = Ndb(path: tempDir)!
|
||||
let our_pubkey = test_pubkey
|
||||
let pool = RelayPool(ndb: ndb)
|
||||
let settings = UserSettingsStore()
|
||||
|
||||
@@ -10,7 +10,7 @@ import Security
|
||||
|
||||
struct SaveKeysView: View {
|
||||
let account: CreateAccountModel
|
||||
let pool: RelayPool = RelayPool(ndb: try! Ndb()!)
|
||||
let pool: RelayPool = RelayPool(ndb: Ndb()!)
|
||||
@State var pub_copied: Bool = false
|
||||
@State var priv_copied: Bool = false
|
||||
@State var loading: Bool = false
|
||||
|
||||
Reference in New Issue
Block a user