diff --git a/services/worker/src/workers/proxy.js b/services/worker/src/workers/proxy.js index c5e51a9..7330302 100644 --- a/services/worker/src/workers/proxy.js +++ b/services/worker/src/workers/proxy.js @@ -78,21 +78,25 @@ export const proxyWorker = async (job) => { const outputPath = join(tmpDir, `proxy-output-${job.id}.mp4`); try { + // Look up the asset row early — check status before doing any work, + // and read media_type for routing decisions below. + const assetRow = await query( + 'SELECT status, media_type FROM assets WHERE id = $1', + [assetId] + ); + const asset = assetRow.rows[0]; + const dbMediaType = asset?.media_type || null; + + if (asset?.status === 'pending_migration') { + console.log(`[proxy] asset ${assetId} is pending_migration, skipping`); + return; + } + // Download original from S3 await job.updateProgress(10); console.log(`[proxy] Downloading ${inputKey} for asset ${assetId}`); await downloadFromS3(S3_BUCKET, inputKey, inputPath); - // Look up the asset row early — we want media_type before deciding how - // to process. That lets us route 'image' assets to the poster path even - // when ffprobe doesn't return a codec name in IMAGE_CODECS (e.g. future - // formats like AVIF / HEIF / JPEG-XL). - const assetRow = await query( - 'SELECT media_type FROM assets WHERE id = $1', - [assetId] - ); - const dbMediaType = assetRow.rows[0]?.media_type || null; - // Reject obviously-empty inputs before handing them to ffmpeg. Aborted // SRT/RTMP recordings end up as 0-byte (or ftyp-only ~1KB) objects in S3 // when the source disconnects before any frame is received; the proxy