Skip to content

Commit

Permalink
Fixed bug in removeOldestTilesAboveLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Feb 28, 2024
1 parent c74f1f9 commit 4153e1c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/src/backend/impls/objectbox/backend/internal_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,19 @@ Future<void> _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();
Expand Down

0 comments on commit 4153e1c

Please sign in to comment.