Skip to content

Commit

Permalink
fix: insert limit of sqlite is smaller than amount of icons (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf committed Sep 21, 2024
1 parent 612a158 commit 9eea8d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/cron-jobs/src/jobs/icons-updater.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stopwatch } from "@homarr/common";
import { splitToNChunks, Stopwatch } from "@homarr/common";
import { EVERY_WEEK } from "@homarr/cron-jobs-core/expressions";
import type { InferInsertModel } from "@homarr/db";
import { db, inArray } from "@homarr/db";
Expand Down Expand Up @@ -79,7 +79,10 @@ export const iconsUpdaterJob = createCronJob("iconsUpdater", EVERY_WEEK, {
}

if (newIcons.length >= 1) {
await transaction.insert(icons).values(newIcons);
// We only insert 5000 icons at a time to avoid SQLite limitations
for (const chunck of splitToNChunks(newIcons, Math.ceil(newIcons.length / 5000))) {
await transaction.insert(icons).values(chunck);
}
}
if (deadIcons.length >= 1) {
await transaction.delete(icons).where(
Expand Down

0 comments on commit 9eea8d4

Please sign in to comment.