Skip to content

Commit 5a1073d

Browse files
committed
fix(sync): chunk the hot-list lookup to stay within SQLite's bind limit
replaceHotList passed every hot number to one IN (...) query. SQLite on Android 10 and 11 allows 999 bound variables, so a hot list over that count would throw. The external blocklist path already chunks by 500; the hot list now uses the same chunk size.
1 parent dd8408d commit 5a1073d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎app/src/main/java/com/sysadmindoc/callshield/data/repository/SyncRepository.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ class SyncRepository(
205205
if (hotNumbers.isEmpty()) {
206206
emptyMap()
207207
} else {
208-
val existingRows = dao.getNumbersByNumbers(hotNumbers.map { it.number })
209-
existingRows.associateBy { it.number }
208+
hotNumbers
209+
.map { it.number }
210+
.chunked(EXTERNAL_BLOCKLIST_LOOKUP_CHUNK_SIZE)
211+
.flatMap { chunk -> dao.getNumbersByNumbers(chunk) }
212+
.associateBy { it.number }
210213
}
211214

212215
val mergedHotNumbers =

0 commit comments

Comments
 (0)