You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
Desktop: Seamless-Updates: used axios for download function (#11068)
This commit is contained in:
@ -136,6 +136,7 @@
|
|||||||
"@types/react-redux": "7.1.33",
|
"@types/react-redux": "7.1.33",
|
||||||
"@types/styled-components": "5.1.32",
|
"@types/styled-components": "5.1.32",
|
||||||
"@types/tesseract.js": "2.0.0",
|
"@types/tesseract.js": "2.0.0",
|
||||||
|
"axios": "^1.7.7",
|
||||||
"electron": "29.4.5",
|
"electron": "29.4.5",
|
||||||
"electron-builder": "24.13.3",
|
"electron-builder": "24.13.3",
|
||||||
"glob": "10.3.16",
|
"glob": "10.3.16",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { createWriteStream } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import { pipeline } from 'stream/promises';
|
||||||
|
import axios from 'axios';
|
||||||
import { GitHubRelease, GitHubReleaseAsset } from '../utils/checkForUpdatesUtils';
|
import { GitHubRelease, GitHubReleaseAsset } from '../utils/checkForUpdatesUtils';
|
||||||
import { downloadFile } from '../../tools/tool-utils';
|
|
||||||
|
|
||||||
|
|
||||||
export interface Context {
|
export interface Context {
|
||||||
repo: string; // {owner}/{repo}
|
repo: string; // {owner}/{repo}
|
||||||
@ -52,11 +53,28 @@ export const downloadFileFromGitHub = async (context: Context, asset: GitHubRele
|
|||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log(`Downloading ${asset.name} from ${asset.url} to ${downloadPath}`);
|
console.log(`Downloading ${asset.name} from ${asset.url} to ${downloadPath}`);
|
||||||
await downloadFile(asset.url, downloadPath, {
|
try {
|
||||||
...defaultApiHeaders(context),
|
const response = await axios({
|
||||||
'Accept': 'application/octet-stream',
|
method: 'get',
|
||||||
});
|
url: asset.url,
|
||||||
return downloadPath;
|
responseType: 'stream',
|
||||||
|
headers: {
|
||||||
|
...defaultApiHeaders(context),
|
||||||
|
'Accept': 'application/octet-stream',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status < 200 || response.status >= 300) {
|
||||||
|
throw new Error(`Failed to download file: Status Code ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await pipeline(response.data, createWriteStream(downloadPath));
|
||||||
|
console.log('Download successful!');
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
return downloadPath;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('Download not successful.');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateReleaseAsset = async (context: Context, assetUrl: string, newName: string) => {
|
export const updateReleaseAsset = async (context: Context, assetUrl: string, newName: string) => {
|
||||||
|
22
yarn.lock
22
yarn.lock
@ -7398,6 +7398,7 @@ __metadata:
|
|||||||
"@types/styled-components": 5.1.32
|
"@types/styled-components": 5.1.32
|
||||||
"@types/tesseract.js": 2.0.0
|
"@types/tesseract.js": 2.0.0
|
||||||
async-mutex: 0.5.0
|
async-mutex: 0.5.0
|
||||||
|
axios: ^1.7.7
|
||||||
codemirror: 5.65.9
|
codemirror: 5.65.9
|
||||||
color: 3.2.1
|
color: 3.2.1
|
||||||
compare-versions: 6.1.0
|
compare-versions: 6.1.0
|
||||||
@ -15019,6 +15020,17 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"axios@npm:^1.7.7":
|
||||||
|
version: 1.7.7
|
||||||
|
resolution: "axios@npm:1.7.7"
|
||||||
|
dependencies:
|
||||||
|
follow-redirects: ^1.15.6
|
||||||
|
form-data: ^4.0.0
|
||||||
|
proxy-from-env: ^1.1.0
|
||||||
|
checksum: 882d4fe0ec694a07c7f5c1f68205eb6dc5a62aecdb632cc7a4a3d0985188ce3030e0b277e1a8260ac3f194d314ae342117660a151fabffdc5081ca0b5a8b47fe
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"axobject-query@npm:^3.1.1":
|
"axobject-query@npm:^3.1.1":
|
||||||
version: 3.2.1
|
version: 3.2.1
|
||||||
resolution: "axobject-query@npm:3.2.1"
|
resolution: "axobject-query@npm:3.2.1"
|
||||||
@ -23453,6 +23465,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"follow-redirects@npm:^1.15.6":
|
||||||
|
version: 1.15.9
|
||||||
|
resolution: "follow-redirects@npm:1.15.9"
|
||||||
|
peerDependenciesMeta:
|
||||||
|
debug:
|
||||||
|
optional: true
|
||||||
|
checksum: 859e2bacc7a54506f2bf9aacb10d165df78c8c1b0ceb8023f966621b233717dab56e8d08baadc3ad3b9db58af290413d585c999694b7c146aaf2616340c3d2a6
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"font-awesome-filetypes@npm:2.1.0":
|
"font-awesome-filetypes@npm:2.1.0":
|
||||||
version: 2.1.0
|
version: 2.1.0
|
||||||
resolution: "font-awesome-filetypes@npm:2.1.0"
|
resolution: "font-awesome-filetypes@npm:2.1.0"
|
||||||
|
Reference in New Issue
Block a user