fix: early PDF validation, type-aware errors, exact job dedup
- Move PDF page count check before MinIO upload and DB record creation to prevent orphaned objects when >500 page PDFs are rejected - Use job type label (PDF page / Video) in media-worker error messages instead of hardcoded "Video processing failed" - Replace LIKE-based idempotency check with exact JSON match to prevent page 1 matching page 11/12/etc substring collisions
This commit is contained in:
@@ -67,8 +67,8 @@ router.post('/:boardId/pdf-pages', async (req, res) => {
|
||||
// Check for existing pending/processing hires job for this page
|
||||
const { db } = require('../db');
|
||||
const existingJob = db.prepare(
|
||||
`SELECT id FROM media_jobs WHERE image_id = ? AND type = 'pdf-hires' AND result_json LIKE ? AND status IN ('queued', 'processing')`
|
||||
).get(imageId, `%"pageNumber":${pageNum}%`);
|
||||
`SELECT id FROM media_jobs WHERE image_id = ? AND type = 'pdf-hires' AND result_json = ? AND status IN ('queued', 'processing')`
|
||||
).get(imageId, JSON.stringify({ pageNumber: pageNum }));
|
||||
|
||||
if (!existingJob) {
|
||||
createMediaJob({
|
||||
@@ -126,8 +126,8 @@ router.post('/:boardId/pdf-thumbnails', async (req, res) => {
|
||||
// Skip if job already pending
|
||||
const { db } = require('../db');
|
||||
const existingJob = db.prepare(
|
||||
`SELECT id FROM media_jobs WHERE image_id = ? AND type = 'pdf-thumbnail' AND result_json LIKE ? AND status IN ('queued', 'processing')`
|
||||
).get(imageId, `%"pageNumber":${pageNum}%`);
|
||||
`SELECT id FROM media_jobs WHERE image_id = ? AND type = 'pdf-thumbnail' AND result_json = ? AND status IN ('queued', 'processing')`
|
||||
).get(imageId, JSON.stringify({ pageNumber: pageNum }));
|
||||
|
||||
if (!existingJob) {
|
||||
createMediaJob({
|
||||
|
||||
Reference in New Issue
Block a user