Always copy seed DB from assets, VACUUM seed to reclaim space

Size comparison was unreliable — SQLite reuses free pages internally,
so adding products didn't change file size. New seed never copied.
Now: always overwrite on every launch (~8MB, <1 sec).
VACUUM reduced seed from 8.5MB to 8.2MB.
This commit is contained in:
4aiman 2026-05-29 15:38:10 +03:00
commit 4d97ba607b
2 changed files with 5 additions and 9 deletions

Binary file not shown.

View file

@ -47,19 +47,15 @@ class MainActivity : TauriActivity() {
processGpsCommand(appDataDir)
Log.d("BalDav", "Command watcher started on ${appDataDir.absolutePath}")
// Copy seed DB from assets to filesDir (Rust can't read Android assets directly).
// Always overwrite — APK updates may contain a newer seed DB.
// Always copy seed DB from assets — ensures APK updates deliver new products.
try {
val seedDest = File(filesDir, "products_seed.db")
val assetSize = assets.open("frontend/data/products_seed.db").use { it.available().toLong() }
if (!seedDest.exists() || seedDest.length() != assetSize) {
assets.open("frontend/data/products_seed.db").use { input ->
seedDest.outputStream().use { output ->
input.copyTo(output)
}
assets.open("frontend/data/products_seed.db").use { input ->
seedDest.outputStream().use { output ->
input.copyTo(output)
}
Log.d("BalDav", "Seed DB copied to ${seedDest.absolutePath} (${seedDest.length()} bytes)")
}
Log.d("BalDav", "Seed DB copied to ${seedDest.absolutePath} (${seedDest.length()} bytes)")
} catch (e: Exception) {
Log.e("BalDav", "Failed to copy seed DB", e)
}