feat: Add image deletion functionality before a specific date and update gallery UI
Some checks failed
Deploy to BeePC / deploy (push) Has been cancelled

This commit is contained in:
2026-02-12 16:14:06 -05:00
parent 9c72b00b1b
commit 854fd199bf
4 changed files with 653 additions and 343 deletions

View File

@@ -224,6 +224,45 @@ router.post('/cleanup', async (req, res) => {
}
});
/**
* POST /api/cleanup/before - Delete images before a specific date
*/
router.post('/cleanup/before', async (req, res) => {
try {
const { beforeDate } = req.body;
if (!beforeDate || typeof beforeDate !== 'string') {
return res.status(400).json({ success: false, error: 'beforeDate is required (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)' });
}
const normalizedInput = beforeDate.replace('T', ' ');
const normalized = normalizedInput.length <= 10
? `${normalizedInput} 00:00:00`
: (normalizedInput.length === 16 ? `${normalizedInput}:00` : normalizedInput);
const imagesToDelete = await database.getImagesBeforeDate(normalized);
let filesDeleted = 0;
for (const image of imagesToDelete) {
const deletedFile = await storage.deleteImageFile(image.file_path);
if (deletedFile) filesDeleted++;
}
const deletedFromDb = await database.deleteImagesBeforeDate(normalized);
res.json({
success: true,
cleanup: {
deletedFromDb,
filesDeleted,
beforeDate: normalized
}
});
} catch (err) {
res.status(500).json({ success: false, error: err.message });
}
});
/**
* GET /api/fetcher/status - Get fetcher status
*/