flyer image fixin
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m27s

This commit is contained in:
2025-12-04 08:53:13 -08:00
parent 9a1b3bda8f
commit 2f64e348fc
3 changed files with 16 additions and 16 deletions

View File

@@ -56,7 +56,7 @@ export const FlyerDisplay: React.FC<FlyerDisplayProps> = ({ imageUrl, store, val
)}
<div className="bg-gray-100 dark:bg-gray-800">
{imageUrl ? (
<img src={imageUrl} alt="Grocery Flyer" className="w-full h-auto object-contain max-h-[60vh] dark:invert dark:hue-rotate-180" />
<img src={`/flyer-images/${imageUrl}`} alt="Grocery Flyer" className="w-full h-auto object-contain max-h-[60vh] dark:invert dark:hue-rotate-180" />
) : (
<div className="w-full h-64 bg-gray-200 dark:bg-gray-700 rounded-lg flex items-center justify-center">
<p className="text-gray-500">Flyer image will be displayed here</p>

View File

@@ -249,7 +249,7 @@ router.post('/flyers/process', optionalAuth, uploadToDisk.single('flyerImage'),
// 2. Prepare flyer data for insertion
const flyerData = {
file_name: originalFileName,
image_url: `/flyer-images/${req.file.filename}`, // Update the URL to point to the new directory
image_url: req.file.filename, // Store only the filename
icon_url: iconUrl, // Add the new icon URL
checksum: checksum,
// Use normalized store name (fallback applied above).

View File

@@ -200,20 +200,20 @@ export const flyerWorker = new Worker<FlyerJobData>(
} finally {
// This block will run after the try/catch, regardless of success or failure.
if (jobSucceeded) {
logger.info(`[Worker] Job ${job.id} succeeded. Cleaning up temporary files.`);
try {
// Delete the generated JPEG images from the PDF conversion.
for (const imagePath of createdImagePaths) {
await fs.unlink(imagePath);
logger.debug(`[Worker] Deleted temporary image: ${imagePath}`);
}
// Finally, delete the original uploaded file (PDF or image).
await fs.unlink(filePath);
logger.debug(`[Worker] Deleted original upload: ${filePath}`);
} catch (cleanupError) {
logger.error(`[Worker] Job ${job.id} completed, but failed during file cleanup.`, { error: cleanupError });
// We don't re-throw here because the main job was successful.
}
logger.info(`[Worker] Job ${job.id} succeeded. File cleanup is disabled; original files will be kept.`);
// try {
// // Delete the generated JPEG images from the PDF conversion.
// for (const imagePath of createdImagePaths) {
// await fs.unlink(imagePath);
// logger.debug(`[Worker] Deleted temporary image: ${imagePath}`);
// }
// // Finally, delete the original uploaded file (PDF or image).
// await fs.unlink(filePath);
// logger.debug(`[Worker] Deleted original upload: ${filePath}`);
// } catch (cleanupError) {
// logger.error(`[Worker] Job ${job.id} completed, but failed during file cleanup.`, { error: cleanupError });
// // We don't re-throw here because the main job was successful.
// }
} else {
logger.warn(`[Worker] Job ${job.id} failed. Temporary files will not be cleaned up to allow for manual inspection.`);
}