A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: speculative quota check pre-archival
Mohamed Bassem53a4598e86dc
diff --git a/apps/workers/workers/crawlerWorker.ts b/apps/workers/workers/crawlerWorker.tsindex d437986d..0659873b 100644--- a/apps/workers/workers/crawlerWorker.ts+++ b/apps/workers/workers/crawlerWorker.ts@@ -1406,6 +1406,20 @@ async function archiveWebpage(},async () => {logger.info(`[Crawler][${jobId}] Will attempt to archive page ...`);++ {+ // Archival is a heavy operation, so we need to check if the user is within reasonable quota before proceeding+ const { error: quotaError } = await tryCatch(+ QuotaService.checkStorageQuota(db, userId, /* estimated size */ 1024),+ );+ if (quotaError) {+ logger.warn(+ `[Crawler][${jobId}] Skipping archival as the user has exceeded their quota: ${quotaError.message}`,+ );+ return null;+ }+ }+const assetId = newAssetId();const assetPath = path.join(os.tmpdir(), assetId);