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();