diff --git a/backend/dist/index.js b/backend/dist/index.js index 4239106..4e5029c 100644 --- a/backend/dist/index.js +++ b/backend/dist/index.js @@ -14843,7 +14843,7 @@ router5.post("/maintenance/download-items/cleanup", requireAuth, async (req, res const retentionDays = Math.min(365, Math.max(1, parseInt(String(req.body?.retentionDays ?? "7"), 10) || 7)); const result = await query( `DELETE FROM telegram_download_items - WHERE status = 'completed' + WHERE status IN ('success', 'failed', 'skipped') AND COALESCE(completed_at, updated_at, created_at) < NOW() - ($1::int * INTERVAL '1 day')`, [retentionDays] ); diff --git a/backend/src/routes/storage.ts b/backend/src/routes/storage.ts index a9b6837..a6c7fe5 100644 --- a/backend/src/routes/storage.ts +++ b/backend/src/routes/storage.ts @@ -213,7 +213,7 @@ router.post('/maintenance/download-items/cleanup', requireAuth, async (req: Requ const retentionDays = Math.min(365, Math.max(1, parseInt(String(req.body?.retentionDays ?? '7'), 10) || 7)); const result = await query( `DELETE FROM telegram_download_items - WHERE status = 'completed' + WHERE status IN ('success', 'failed', 'skipped') AND COALESCE(completed_at, updated_at, created_at) < NOW() - ($1::int * INTERVAL '1 day')`, [retentionDays] ); diff --git a/backend/src/routes/storageMaintenanceCleanup.test.ts b/backend/src/routes/storageMaintenanceCleanup.test.ts new file mode 100644 index 0000000..660c028 --- /dev/null +++ b/backend/src/routes/storageMaintenanceCleanup.test.ts @@ -0,0 +1,9 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs'; + +const source = fs.readFileSync(new URL('./storage.ts', import.meta.url), 'utf8'); + +assert.match(source, /status\s+IN\s*\(\s*'success'\s*,\s*'failed'\s*,\s*'skipped'\s*\)/); +assert.doesNotMatch(source, /status\s*=\s*'completed'/); + +console.log('storage maintenance download item cleanup statuses ok');