Breaking after 1000 purges.

This commit is contained in:
Eric van der Vlist 2023-02-13 10:11:46 +01:00
parent 19aaaba3f8
commit 01554e3383
1 changed files with 5 additions and 3 deletions

View File

@ -239,6 +239,7 @@ export const watchDbLegacy = async () => {
const deletedDocs = await getDeletedDocs(); const deletedDocs = await getDeletedDocs();
let i = 0;
if (deletedDocs.length > 0) { if (deletedDocs.length > 0) {
console.log({ console.log({
caller: 'watchDbLegacy / purge', caller: 'watchDbLegacy / purge',
@ -248,7 +249,6 @@ export const watchDbLegacy = async () => {
deletedDocs, deletedDocs,
state: state(), state: state(),
}); });
let i = 0;
for (const doc of deletedDocs) { for (const doc of deletedDocs) {
await sleep(10); await sleep(10);
try { try {
@ -269,12 +269,14 @@ export const watchDbLegacy = async () => {
doc, doc,
}); });
} }
if (i === 10000) { if (i === 20000) {
break; break;
} }
} }
} }
await sleep(60000); if (i !== deletedDocs.length) {
await sleep(60000);
}
} }
}); });
}; };