Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Android

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Run unit tests
run: bash ./gradlew test
42 changes: 0 additions & 42 deletions .github/workflows/deno.yml

This file was deleted.

29 changes: 24 additions & 5 deletions app/src/main/java/hu/regelo/app/data/EncryptedLocalDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ internal object EncryptedLocalDatabase {
} finally {
plainDb.close()
}
check(temporary.createNewFile()) {
"A titkosított adatbázis ideiglenes fájlja nem hozható létre."
}
listOf("-wal", "-shm").forEach { suffix ->
val sidecar = File(database.absolutePath + suffix)
check(!sidecar.exists() || sidecar.delete()) {
Expand All @@ -103,22 +106,38 @@ internal object EncryptedLocalDatabase {
}

try {
database.copyTo(temporary, overwrite = true)
val migrationDb = SQLiteDatabase.openDatabase(
temporary.absolutePath,
database.absolutePath,
null,
SQLiteDatabase.OPEN_READWRITE,
)
try {
verifyReadable(migrationDb)
migrationDb.changePassword(passphrase)
verifyReadable(migrationDb)
val schemaVersion = migrationDb.version
migrationDb.execSQL(
"ATTACH DATABASE ? AS encrypted KEY ?",
arrayOf(temporary.absolutePath, passphrase),
)
try {
migrationDb.rawQuery("SELECT sqlcipher_export('encrypted')", null).use { cursor ->
check(cursor.moveToFirst() && cursor.getInt(0) == 0) {
"Az SQLite-adatbázis titkosított exportja sikertelen."
}
}
migrationDb.execSQL("PRAGMA encrypted.user_version = $schemaVersion")
migrationDb.rawQuery("PRAGMA encrypted.user_version", null).use { cursor ->
check(cursor.moveToFirst() && cursor.getInt(0) == schemaVersion) {
"Az adatbázis sémaverziójának exportja sikertelen."
}
}
} finally {
migrationDb.execSQL("DETACH DATABASE encrypted")
}
} finally {
migrationDb.close()
}
verifyEncryptedDatabase(temporary, passphrase)
Os.rename(temporary.absolutePath, database.absolutePath)
verifyEncryptedDatabase(database, passphrase)
} catch (e: Exception) {
temporary.delete()
throw IllegalStateException(
Expand Down
Loading