Added a button to the settings screen to trigger a re-migration of the database

This commit is contained in:
Morgan Pretty 2022-06-23 15:52:50 +10:00
parent 5722cfe7d0
commit 346ce3d24a
2 changed files with 12 additions and 2 deletions

View file

@ -299,6 +299,8 @@ final class SettingsVC: BaseVC, AvatarViewHelperDelegate {
return button
}
let debugReMigrateButton = getSettingButton(withTitle: "DEBUG - Re-Migrate Database", color: Colors.destructive, action: #selector(remigrateDatabase))
let pathButton = getSettingButton(withTitle: NSLocalizedString("vc_path_title", comment: ""), color: Colors.text, action: #selector(showPath))
let pathStatusView = PathStatusView()
pathStatusView.set(.width, to: PathStatusView.size)
@ -309,6 +311,8 @@ final class SettingsVC: BaseVC, AvatarViewHelperDelegate {
pathStatusView.autoVCenterInSuperview()
return [
getSeparator(),
debugReMigrateButton,
getSeparator(),
pathButton,
getSeparator(),
@ -588,6 +592,12 @@ final class SettingsVC: BaseVC, AvatarViewHelperDelegate {
navigationController!.present(shareVC, animated: true, completion: nil)
}
@objc private func remigrateDatabase() {
GRDBStorage.deleteDatabaseFiles()
try? GRDBStorage.deleteDbKeys()
exit(1)
}
@objc private func showPath() {
let pathVC = PathVC()
navigationController!.pushViewController(pathVC, animated: true)

View file

@ -297,13 +297,13 @@ public final class GRDBStorage {
// TODO: Delete Profiles on Disk?
}
private static func deleteDatabaseFiles() {
public/*private*/ static func deleteDatabaseFiles() {
OWSFileSystem.deleteFile(databasePath)
OWSFileSystem.deleteFile(databasePathShm)
OWSFileSystem.deleteFile(databasePathWal)
}
private static func deleteDbKeys() throws {
public/*private*/ static func deleteDbKeys() throws {
try SSKDefaultKeychainStorage.shared.remove(service: keychainService, key: dbCipherKeySpecKey)
}