Skip to content

Commit

Permalink
Close cursor in retrieveConfigLastUpdateTimestamp (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
SessionHero01 authored Oct 14, 2024
1 parent ed1bddd commit ecfa5d3
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ class ConfigDatabase(context: Context, helper: SQLCipherOpenHelper): Database(co
}

fun retrieveConfigLastUpdateTimestamp(variant: String, publicKey: String): Long {
val db = readableDatabase
val cursor = db.query(TABLE_NAME, arrayOf(TIMESTAMP), VARIANT_AND_PUBKEY_WHERE, arrayOf(variant, publicKey),null, null, null)
if (cursor == null) return 0
if (!cursor.moveToFirst()) return 0
return (cursor.getLongOrNull(cursor.getColumnIndex(TIMESTAMP)) ?: 0)
return readableDatabase
.query(TABLE_NAME, arrayOf(TIMESTAMP), VARIANT_AND_PUBKEY_WHERE, arrayOf(variant, publicKey), null, null, null)
?.use { cursor ->
if (cursor.moveToFirst()) {
cursor.getLongOrNull(cursor.getColumnIndex(TIMESTAMP))
} else {
null
}
} ?: 0L
}
}

0 comments on commit ecfa5d3

Please sign in to comment.