diff --git a/src/app.ts b/src/app.ts index 49f856fd20..ff40a111ee 100644 --- a/src/app.ts +++ b/src/app.ts @@ -12,6 +12,7 @@ import assets from "./routes/assets.js"; import routes from "./routes/routes.js"; import custom from "./routes/custom.js"; import error_handlers from "./routes/error_handlers.js"; +import { startScheduledCleanup } from "./services/erase.js"; await import('./services/handlers'); await import('./becca/becca_loader'); @@ -61,6 +62,8 @@ await import('./services/consistency_checks'); await import('./services/scheduler'); +startScheduledCleanup(); + if (utils.isElectron()) { (await import('@electron/remote/main')).initialize(); } diff --git a/src/services/erase.ts b/src/services/erase.ts index 5b7261ec9f..1d7dcd7389 100644 --- a/src/services/erase.ts +++ b/src/services/erase.ts @@ -177,14 +177,16 @@ function eraseScheduledAttachments(eraseUnusedAttachmentsAfterSeconds: number | eraseAttachments(attachmentIdsToErase); } -sqlInit.dbReady.then(() => { - // first cleanup kickoff 5 minutes after startup - setTimeout(cls.wrap(() => eraseDeletedEntities()), 5 * 60 * 1000); - setTimeout(cls.wrap(() => eraseScheduledAttachments()), 6 * 60 * 1000); - - setInterval(cls.wrap(() => eraseDeletedEntities()), 4 * 3600 * 1000); - setInterval(cls.wrap(() => eraseScheduledAttachments()), 3600 * 1000); -}); +export function startScheduledCleanup() { + sqlInit.dbReady.then(() => { + // first cleanup kickoff 5 minutes after startup + setTimeout(cls.wrap(() => eraseDeletedEntities()), 5 * 60 * 1000); + setTimeout(cls.wrap(() => eraseScheduledAttachments()), 6 * 60 * 1000); + + setInterval(cls.wrap(() => eraseDeletedEntities()), 4 * 3600 * 1000); + setInterval(cls.wrap(() => eraseScheduledAttachments()), 3600 * 1000); + }); +} export default { eraseDeletedNotesNow, @@ -192,5 +194,5 @@ export default { eraseNotesWithDeleteId, eraseUnusedBlobs, eraseAttachments, - eraseRevisions + eraseRevisions, };