Skip to content

Commit

Permalink
Desktop: Seamless-Updates: used url instead of browser url and added …
Browse files Browse the repository at this point in the history
…api heade… (laurent22#11049)
  • Loading branch information
AliceHincu authored Sep 15, 2024
1 parent 8931a68 commit 017480e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/app-desktop/tools/githubReleasesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
export const downloadFile = async (context: Context, asset: GitHubReleaseAsset, destinationDir: string): Promise<string> => {
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}`);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-desktop/tools/modifyReleaseAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 017480e

Please sign in to comment.