From 4153e1c7a9eda2763f82771e30ffca05db05c32b Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Wed, 28 Feb 2024 20:48:40 +0000 Subject: [PATCH] Fixed bug in `removeOldestTilesAboveLimit` --- .../objectbox/backend/internal_worker.dart | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/src/backend/impls/objectbox/backend/internal_worker.dart b/lib/src/backend/impls/objectbox/backend/internal_worker.dart index 31120c49..3476c451 100644 --- a/lib/src/backend/impls/objectbox/backend/internal_worker.dart +++ b/lib/src/backend/impls/objectbox/backend/internal_worker.dart @@ -551,17 +551,19 @@ Future _worker( final numToRemove = store.length - tilesLimit; - if (numToRemove <= 0) sendRes(id: cmd.id, data: {'numOrphans': 0}); - - tilesQuery.limit = numToRemove; - - sendRes( - id: cmd.id, - data: { - 'numOrphans': - deleteTiles(storeName: storeName, tilesQuery: tilesQuery), - }, - ); + if (numToRemove <= 0) { + sendRes(id: cmd.id, data: {'numOrphans': 0}); + } else { + tilesQuery.limit = numToRemove; + + sendRes( + id: cmd.id, + data: { + 'numOrphans': + deleteTiles(storeName: storeName, tilesQuery: tilesQuery), + }, + ); + } storeQuery.close(); tilesQuery.close();