You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-30 23:44:55 +02:00
Desktop: Seamless-Updates: used url instead of browser url and added api heade… (#11049)
This commit is contained in:
@ -45,15 +45,20 @@ export const getTargetRelease = async (context: Context, targetTag: string): Pro
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Download a file from Joplin Desktop releases
|
// 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);
|
const downloadPath = path.join(destinationDir, asset.name);
|
||||||
if (!fs.existsSync(destinationDir)) {
|
if (!fs.existsSync(destinationDir)) {
|
||||||
fs.mkdirSync(destinationDir);
|
fs.mkdirSync(destinationDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log(`Downloading ${asset.name} to ${downloadPath}`);
|
console.log(`Downloading ${asset.name} from ${asset.url} to ${downloadPath}`);
|
||||||
const response = await fetch(asset.browser_download_url);
|
const response = await fetch(asset.url, {
|
||||||
|
headers: {
|
||||||
|
...defaultApiHeaders(context),
|
||||||
|
'Accept': 'application/octet-stream',
|
||||||
|
},
|
||||||
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to download file: Status Code ${response.status}`);
|
throw new Error(`Failed to download file: Status Code ${response.status}`);
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ const createReleaseAssets = async (context: Context, release: GitHubRelease) =>
|
|||||||
let zipPath;
|
let zipPath;
|
||||||
for (const asset of release.assets) {
|
for (const asset of release.assets) {
|
||||||
if (asset.name.endsWith('arm64.zip')) {
|
if (asset.name.endsWith('arm64.zip')) {
|
||||||
zipPath = await downloadFile(asset, downloadDir);
|
zipPath = await downloadFile(context, asset, downloadDir);
|
||||||
} else if (asset.name.endsWith('arm64.DMG')) {
|
} else if (asset.name.endsWith('arm64.DMG')) {
|
||||||
dmgPath = await downloadFile(asset, downloadDir);
|
dmgPath = await downloadFile(context, asset, downloadDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user