From 778b39b9bd6b0968cf68ffad185ca9a8cd39bb2c Mon Sep 17 00:00:00 2001 From: Stephan Raab Date: Mon, 15 Apr 2024 14:39:43 +0200 Subject: [PATCH] Bugfix: Failed to save image (#1608) Signed-off-by: Stephan Raab --- src/webcontents-handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webcontents-handler.ts b/src/webcontents-handler.ts index f8bf0d4..ce60066 100644 --- a/src/webcontents-handler.ts +++ b/src/webcontents-handler.ts @@ -33,7 +33,7 @@ import { import url from "url"; import fs from "fs"; import fetch from "node-fetch"; -import { pipeline } from "stream"; +import { pipeline } from "stream/promises"; import path from "path"; import { _t } from "./language-helper"; @@ -165,7 +165,7 @@ function onLinkContextMenu(ev: Event, params: ContextMenuParams, webContents: We const resp = await fetch(url); if (!resp.ok) throw new Error(`unexpected response ${resp.statusText}`); if (!resp.body) throw new Error(`unexpected response has no body ${resp.statusText}`); - pipeline(resp.body, fs.createWriteStream(filePath)); + await pipeline(resp.body, fs.createWriteStream(filePath)); } } catch (err) { console.error(err);