Skip to content

Commit 78346c2

Browse files
committed
check token fixed when app is updating
1 parent 90141e4 commit 78346c2

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/main/updater/services/mac-os/check-for-update.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export class CheckForUpdateService {
2222

2323
const downloadsPath = app.getPath("downloads");
2424
const folderPath = path.join(downloadsPath, folders.download);
25-
25+
const token = process.env.GH_TOKEN;
2626
const response = await fetch(`${restApi.urls.githubReleases}/latest`, {
2727
method: "GET",
2828
headers: {
29-
Authorization: `Bearer ${process.env.GH_TOKEN}`,
29+
...(token !== undefined ? { Authorization: `Bearer ${token}` } : {}),
3030
Accept: "application/json",
3131
},
3232
});

src/main/updater/services/mac-os/download-file.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ export class DownloadFileService {
2929
}
3030

3131
const filePath = path.join(folderPath, name);
32+
const token = process.env.GH_TOKEN;
3233
const res = await fetch(
3334
`${restApi.urls.githubReleases}/assets/${assetId}`,
3435
{
3536
method: "GET",
3637
headers: {
37-
Authorization: `Bearer ${process.env.GH_TOKEN}`,
38+
...(token !== undefined
39+
? { Authorization: `Bearer ${token}` }
40+
: {}),
3841
Accept: "application/octet-stream",
3942
},
4043
}

src/main/updater/services/windows/set-feed-url.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ export class SetFeedUrlService {
1111

1212
setFeedURL() {
1313
if (isPlatform("win32") && !isDev()) {
14+
const token = process.env.GH_TOKEN;
1415
autoUpdater.disableDifferentialDownload = true;
1516
autoUpdater.setFeedURL({
1617
provider: "github",
1718
repo: publishOptions.repo,
1819
owner: publishOptions.owner,
1920
private: true,
20-
token: process.env.GH_TOKEN,
21+
...(token !== undefined
22+
? {
23+
token: process.env.GH_TOKEN,
24+
}
25+
: {}),
2126
});
2227
}
2328
}

0 commit comments

Comments
 (0)