diff --git a/assets/build/nsis.nsh b/assets/build/nsis.nsh index 90ee1b3df..8fb2f57ed 100644 --- a/assets/build/nsis.nsh +++ b/assets/build/nsis.nsh @@ -38,3 +38,14 @@ ManifestDPIAware true DeleteRegKey SHELL_CONTEXT "Software\Classes\ipfs" DeleteRegKey SHELL_CONTEXT "Software\Classes\dweb" !macroend + +!macro customInit + # https://github.com/ipfs-shipyard/ipfs-desktop/pull/1679#issuecomment-705630973 + ${if} $installMode == "all" + ${IfNot} ${UAC_IsAdmin} + ShowWindow $HWNDPARENT ${SW_HIDE} + !insertmacro UAC_RunElevated + Quit + ${endif} + ${endif} +!macroend diff --git a/electron-builder.yml b/electron-builder.yml index a7cae33c7..89847919b 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -43,6 +43,7 @@ nsis: oneClick: false warningsAsErrors: false perMachine: false + allowElevation: true allowToChangeInstallationDirectory: true linux: diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index 2f2058d11..f0a3b6f2e 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -1,4 +1,4 @@ -const { app, shell } = require('electron') +const { shell } = require('electron') const { autoUpdater } = require('electron-updater') const i18n = require('i18next') const logger = require('../common/logger') @@ -7,26 +7,10 @@ const { showDialog } = require('../dialogs') const quitAndInstall = require('./quit-and-install') let feedback = false -let installOnQuit = false function setup (ctx) { autoUpdater.autoDownload = false - autoUpdater.autoInstallOnAppQuit = false - - /** - * this replaces the autoInstallOnAppQuit feature of autoUpdater, which causes the app - * to uninstall itself if it is installed for all users on a windows system. - * - * More info: https://github.com/ipfs-shipyard/ipfs-desktop/issues/1514 - * Should be removed once https://github.com/electron-userland/electron-builder/issues/4815 is resolved. - */ - app.once('before-quit', ev => { - if (installOnQuit) { - ev.preventDefault() - installOnQuit = false - autoUpdater.quitAndInstall(false, false) - } - }) + autoUpdater.autoInstallOnAppQuit = true autoUpdater.on('error', err => { logger.error(`[updater] ${err.toString()}`) @@ -98,8 +82,6 @@ function setup (ctx) { autoUpdater.on('update-downloaded', ({ version }) => { logger.info('[updater] update downloaded') - installOnQuit = true - const doIt = () => { setImmediate(() => { quitAndInstall(ctx)