From 017480eb4539f5fda0b51a6b727b60293348d1f1 Mon Sep 17 00:00:00 2001 From: Alice <53339016+AliceHincu@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:02:02 +0300 Subject: [PATCH] =?UTF-8?q?Desktop:=20Seamless-Updates:=20used=20url=20ins?= =?UTF-8?q?tead=20of=20browser=20url=20and=20added=20api=20heade=E2=80=A6?= =?UTF-8?q?=20(#11049)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/app-desktop/tools/githubReleasesUtils.ts | 11 ++++++++--- packages/app-desktop/tools/modifyReleaseAssets.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/app-desktop/tools/githubReleasesUtils.ts b/packages/app-desktop/tools/githubReleasesUtils.ts index f3e13ad074..4db186ee4f 100644 --- a/packages/app-desktop/tools/githubReleasesUtils.ts +++ b/packages/app-desktop/tools/githubReleasesUtils.ts @@ -45,15 +45,20 @@ export const getTargetRelease = async (context: Context, targetTag: string): Pro }; // Download a file from Joplin Desktop releases -export const downloadFile = async (asset: GitHubReleaseAsset, destinationDir: string): Promise => { +export const downloadFile = async (context: Context, asset: GitHubReleaseAsset, destinationDir: string): Promise => { const downloadPath = path.join(destinationDir, asset.name); if (!fs.existsSync(destinationDir)) { fs.mkdirSync(destinationDir); } /* eslint-disable no-console */ - console.log(`Downloading ${asset.name} to ${downloadPath}`); - const response = await fetch(asset.browser_download_url); + console.log(`Downloading ${asset.name} from ${asset.url} to ${downloadPath}`); + const response = await fetch(asset.url, { + headers: { + ...defaultApiHeaders(context), + 'Accept': 'application/octet-stream', + }, + }); if (!response.ok) { throw new Error(`Failed to download file: Status Code ${response.status}`); } diff --git a/packages/app-desktop/tools/modifyReleaseAssets.ts b/packages/app-desktop/tools/modifyReleaseAssets.ts index d98b33f7d2..9d14859cf5 100644 --- a/packages/app-desktop/tools/modifyReleaseAssets.ts +++ b/packages/app-desktop/tools/modifyReleaseAssets.ts @@ -35,9 +35,9 @@ const createReleaseAssets = async (context: Context, release: GitHubRelease) => let zipPath; for (const asset of release.assets) { if (asset.name.endsWith('arm64.zip')) { - zipPath = await downloadFile(asset, downloadDir); + zipPath = await downloadFile(context, asset, downloadDir); } else if (asset.name.endsWith('arm64.DMG')) { - dmgPath = await downloadFile(asset, downloadDir); + dmgPath = await downloadFile(context, asset, downloadDir); } }