Proper way to emit outdated cookies

This commit is contained in:
tarsin committed 2023-03-02 21:24:48 +08:00
1 parent c1852f4728
commit dc47f68ff3
1 file changed
+1 -3
@@ -77,11 +77,9 @@ abstract class CookiesDatabase : RoomDatabase() {
internal class CookieDatabase(context: Context, name: String) {
private val cookiesList by lazy {
val now = System.currentTimeMillis()
val statement = db.compileStatement("DELETE FROM OK_HTTP_3_COOKIE WHERE _id = ?;")
db.cookiesDao().list().mapNotNull {
it.takeUnless { !it.persistent || it.expiresAt <= now } ?: run {
statement.bindLong(1, it.id!!)
statement.executeUpdateDelete()
db.cookiesDao().delete(it)
null
}
}.toMutableList()