Forgot to close DB before importing process

This will clear the database lock file before closing the application, ensuring that during the second startup the application does not see anything weird with the data. Not closing the database before import can lead to weird behavior.
This commit is contained in:
Nacho 2025-01-18 01:05:45 +01:00
parent 42dd87f0c4
commit 542072c238

View File

@ -91,6 +91,8 @@ class NewSettingsScreenControllerImpl(
private fun importDatabase(roomDbName: String, sourceUri: Uri) {
context.lifecycleScope.launch(Dispatchers.IO) {
try {
var application = context.applicationContext as VBHelper
if (!getFileNameFromUri(sourceUri)!!.endsWith(".vbhelper")) {
context.runOnUiThread {
Toast.makeText(context, "Invalid file format", Toast.LENGTH_SHORT).show()
@ -98,6 +100,8 @@ class NewSettingsScreenControllerImpl(
return@launch
}
application.container.db.close()
val dbPath = context.getDatabasePath(roomDbName)
val shmFile = File(dbPath.parent, "$roomDbName-shm")
val walFile = File(dbPath.parent, "$roomDbName-wal")