Skip to content

Commit 52f2c24

Browse files
authored
fix: windows auto-update (#1679)
1 parent 1ffd652 commit 52f2c24

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

assets/build/nsis.nsh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ ManifestDPIAware true
3838
DeleteRegKey SHELL_CONTEXT "Software\Classes\ipfs"
3939
DeleteRegKey SHELL_CONTEXT "Software\Classes\dweb"
4040
!macroend
41+
42+
!macro customInit
43+
# https://github.com/ipfs-shipyard/ipfs-desktop/pull/1679#issuecomment-705630973
44+
${if} $installMode == "all"
45+
${IfNot} ${UAC_IsAdmin}
46+
ShowWindow $HWNDPARENT ${SW_HIDE}
47+
!insertmacro UAC_RunElevated
48+
Quit
49+
${endif}
50+
${endif}
51+
!macroend

electron-builder.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ nsis:
4343
oneClick: false
4444
warningsAsErrors: false
4545
perMachine: false
46+
allowElevation: true
4647
allowToChangeInstallationDirectory: true
4748

4849
linux:

src/auto-updater/index.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { app, shell } = require('electron')
1+
const { shell } = require('electron')
22
const { autoUpdater } = require('electron-updater')
33
const i18n = require('i18next')
44
const logger = require('../common/logger')
@@ -7,26 +7,10 @@ const { showDialog } = require('../dialogs')
77
const quitAndInstall = require('./quit-and-install')
88

99
let feedback = false
10-
let installOnQuit = false
1110

1211
function setup (ctx) {
1312
autoUpdater.autoDownload = false
14-
autoUpdater.autoInstallOnAppQuit = false
15-
16-
/**
17-
* this replaces the autoInstallOnAppQuit feature of autoUpdater, which causes the app
18-
* to uninstall itself if it is installed for all users on a windows system.
19-
*
20-
* More info: https://github.com/ipfs-shipyard/ipfs-desktop/issues/1514
21-
* Should be removed once https://github.com/electron-userland/electron-builder/issues/4815 is resolved.
22-
*/
23-
app.once('before-quit', ev => {
24-
if (installOnQuit) {
25-
ev.preventDefault()
26-
installOnQuit = false
27-
autoUpdater.quitAndInstall(false, false)
28-
}
29-
})
13+
autoUpdater.autoInstallOnAppQuit = true
3014

3115
autoUpdater.on('error', err => {
3216
logger.error(`[updater] ${err.toString()}`)
@@ -98,8 +82,6 @@ function setup (ctx) {
9882
autoUpdater.on('update-downloaded', ({ version }) => {
9983
logger.info('[updater] update downloaded')
10084

101-
installOnQuit = true
102-
10385
const doIt = () => {
10486
setImmediate(() => {
10587
quitAndInstall(ctx)

0 commit comments

Comments
 (0)