Skip to content

Commit

Permalink
fix: windows auto-update feature when selecting install for all users (
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelramalho19 authored Jun 26, 2020
1 parent c9089fc commit c26525f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/auto-updater/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { shell } = require('electron')
const { app, shell } = require('electron')
const { autoUpdater } = require('electron-updater')
const i18n = require('i18next')
const logger = require('../common/logger')
Expand All @@ -7,10 +7,26 @@ const { showDialog } = require('../dialogs')
const quitAndInstall = require('./quit-and-install')

let feedback = false
let installOnQuit = false

function setup (ctx) {
autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true
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.on('error', err => {
logger.error(`[updater] ${err.toString()}`)
Expand Down Expand Up @@ -82,6 +98,8 @@ function setup (ctx) {
autoUpdater.on('update-downloaded', ({ version }) => {
logger.info('[updater] update downloaded')

installOnQuit = true

const doIt = () => {
setImmediate(() => {
quitAndInstall(ctx)
Expand Down

0 comments on commit c26525f

Please sign in to comment.