Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows auto-update feature when selecting install for all users #1556

Merged
merged 3 commits into from
Jun 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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