From b4eeabb3662fab7be12fc842986e663be9ed1eea Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:00:30 -0400 Subject: [PATCH] [MM-60232] Fix a crash in Linux when trying to create a thumbnail from an image (#3147) * [MM-60232] Fix a crash in Linux when trying to create a thumbnail from an image * Fix lint * Cap at 1MB * Fix crash again --- src/main/downloadsManager.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/downloadsManager.ts b/src/main/downloadsManager.ts index 51f9f8fc..49cd5bbe 100644 --- a/src/main/downloadsManager.ts +++ b/src/main/downloadsManager.ts @@ -635,7 +635,15 @@ export class DownloadsManager extends JsonFileManager { let thumbnailData; if (state === 'completed' && item.getMimeType().toLowerCase().startsWith('image/')) { - thumbnailData = (await nativeImage.createThumbnailFromPath(overridePath ?? item.getSavePath(), {height: 32, width: 32})).toDataURL(); + // Linux doesn't support the thumbnail creation so we have to use the base function + if (process.platform === 'linux') { + // We also will cap this at 1MB so as to not inflate the memory usage of the downloads dropdown + if (item.getReceivedBytes() < 1000000) { + thumbnailData = (await nativeImage.createFromPath(overridePath ?? item.getSavePath())).toDataURL(); + } + } else { + thumbnailData = (await nativeImage.createThumbnailFromPath(overridePath ?? item.getSavePath(), {height: 32, width: 32})).toDataURL(); + } } return {