Skip to content

Commit c2cceb9

Browse files
committed
connecting room
1 parent b441d90 commit c2cceb9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/data/db-room/src/androidMain/kotlin/com/softartdev/notedelight/db/AndroidDatabaseHolder.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import com.softartdev.notedelight.repository.SafeRepo
99
class AndroidDatabaseHolder(
1010
context: Context,
1111
passphrase: CharSequence,
12-
name: String? = SafeRepo.DB_NAME
1312
) : RoomDbHolder {
13+
private val dbPath: String = context.getDatabasePath(SafeRepo.DB_NAME).absolutePath
14+
1415
val noteDatabase: NoteDatabase = Room
15-
.databaseBuilder(context, NoteDatabase::class.java, name)
16+
.databaseBuilder(context, NoteDatabase::class.java, dbPath)
1617
.openHelperFactory(SafeHelperFactory.fromUser(SpannableStringBuilder(passphrase)))
1718
.fallbackToDestructiveMigrationOnDowngrade(false)
1819
.build()

core/domain/src/commonMain/kotlin/com/softartdev/notedelight/usecase/crypt/CheckPasswordUseCase.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class CheckPasswordUseCase(private val safeRepo: SafeRepo) {
1010
safeRepo.closeDatabase()
1111
val passphrase = StringBuilder(pass) // threadsafe
1212
safeRepo.buildDbIfNeed(passphrase)
13+
val count: Long = safeRepo.noteDAO.count
14+
Napier.i("Checked pass on DB with $count notes")
1315
true
1416
} catch (t: Throwable) {
1517
Napier.i(message = "Incorrect password", throwable = t)

0 commit comments

Comments
 (0)