1.0.14 Package Updates and Assets fix

This commit is contained in:
Allan Carr
2025-07-23 17:59:13 -07:00
parent d2bf897e2f
commit b23e446ed3
12 changed files with 216 additions and 57 deletions

View File

@@ -48,8 +48,21 @@ const thumbnailWorker = new Worker(
logger.debug(`[ThumbnailWorker] Completed thumbnail generation for ${file}`);
return result;
} catch (error) {
// Handle VipsJpeg and other thumbnail generation errors gracefully
const errorMessage = (error as Error).message;
if (
errorMessage.includes("VipsJpeg") ||
errorMessage.includes("Premature end") ||
errorMessage.includes("JPEG") ||
errorMessage.includes("SOS")
) {
logger.warning(`[ThumbnailWorker] Image processing error for ${file}, returning default icon:`, errorMessage);
return path.relative(path.dirname(file), AssetPaths.File);
}
logger.error(`[ThumbnailWorker] Error generating thumbnail for ${file}:`, error);
throw error;
// For other errors, still return default icon instead of throwing
return path.relative(path.dirname(file), AssetPaths.File);
}
},
{
@@ -126,23 +139,50 @@ async function processThumbnail(file: string, job?: Job): Promise<string> {
if (["application/pdf", "image/heic", "image/heif"].includes(type.mime)) {
logger.debug(`[ThumbnailWorker] Generating PDF/HEIC thumbnail for: ${file}`);
await generatePdfThumbnail(file, thumbPath);
try {
await generatePdfThumbnail(file, thumbPath);
} catch (pdfError) {
logger.warning(`[ThumbnailWorker] Failed to generate PDF/HEIC thumbnail for ${file}:`, {
error: pdfError,
message: (pdfError as Error).message
});
// Don't throw, just return the default file icon
return path.relative(path.dirname(file), AssetPaths.File);
}
} else if (type.mime.startsWith("video")) {
logger.debug(`[ThumbnailWorker] Generating video thumbnail for: ${file}`);
await simpleThumb(file, thumbPath, "250x?");
try {
await simpleThumb(file, thumbPath, "250x?");
} catch (videoError) {
logger.warning(`[ThumbnailWorker] Failed to generate video thumbnail for ${file}:`, {
error: videoError,
message: (videoError as Error).message
});
// Don't throw, just return the default file icon
return path.relative(path.dirname(file), AssetPaths.File);
}
} else {
logger.debug(`[ThumbnailWorker] Generating image thumbnail for: ${file}`);
const thumbnailBuffer = await imageThumbnail(file, {
responseType: "buffer",
height: 250,
width: 250
});
await fs.writeFile(thumbPath, thumbnailBuffer);
try {
const thumbnailBuffer = await imageThumbnail(file, {
responseType: "buffer",
height: 250,
width: 250
});
await fs.writeFile(thumbPath, thumbnailBuffer);
} catch (thumbnailError) {
logger.warning(`[ThumbnailWorker] Failed to generate image thumbnail for ${file}:`, {
error: thumbnailError,
message: (thumbnailError as Error).message
});
// Don't throw, just return the default file icon
return path.relative(path.dirname(file), AssetPaths.File);
}
}
return path.relative(path.dirname(file), thumbPath);
} catch (error) {
logger.error("[ThumbnailWorker] Error generating thumbnail:", {
logger.warning("[ThumbnailWorker] Could not generate thumbnail, returning default file icon:", {
thumbPath,
error,
message: (error as Error).message
@@ -189,7 +229,7 @@ export default async function GenerateThumbnail(file: string): Promise<string> {
logger.debug(`[GenerateThumbnail] Job completed for ${file}`);
return result as string;
} catch (error) {
logger.error(`[GenerateThumbnail] Job failed for ${file}:`, error);
logger.warning(`[GenerateThumbnail] Job failed for ${file}, returning default file icon:`, error);
return path.relative(path.dirname(file), AssetPaths.File);
}
}