This commit is contained in:
Alexander Bondarenko
2024-03-29 15:36:22 +03:00
parent fe4176357e
commit 20b7d6623b
+6 -1
View File
@@ -243,10 +243,15 @@ chatMigrateInitKey dbFilePrefix dbKey keepKey confirm backgroundMode = runExcept
newChatController db user_ defaultMobileConfig (mobileChatOpts dbFilePrefix) backgroundMode
migrate createStore dbFile confirmMigrations =
ExceptT $
(first (DBMErrorMigration dbFile) <$> createStore dbFile dbKey keepKey confirmMigrations)
(first (DBMErrorMigration dbFile) <$> createStore' dbFile dbKey keepKey confirmMigrations)
`catch` (pure . checkDBError)
`catchAll` (pure . dbError)
where
createStore' dbFilePath dbKey keepKey _confirmMigrations =
let dbDir = takeDirectory dbFilePath
createDirectoryIfMissing True dbDir
Right <$> connectSQLiteStore dbFilePath dbKey keepKey
checkDBError e = case sqlError e of
DB.ErrorNotADatabase -> Left $ DBMErrorNotADatabase dbFile
_ -> dbError e