Skip to content

Commit

Permalink
[MM-60232] Fix a crash in Linux when trying to create a thumbnail fro…
Browse files Browse the repository at this point in the history
…m 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
  • Loading branch information
devinbinnie authored Sep 19, 2024
1 parent b03bb69 commit b4eeabb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/downloadsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,15 @@ export class DownloadsManager extends JsonFileManager<DownloadedItems> {

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 {
Expand Down

0 comments on commit b4eeabb

Please sign in to comment.