Ensure that default file/protocol handlers are re-installed after updating. (#997)

Previously, they were only installed when the preference was changed.
This caused the handlers to point to non-existing files after updates
occurred and older versions were removed by Squirrel.

Closes #791, #911.
This commit is contained in:
Benjamin Tan
2021-09-23 09:11:53 +08:00
committed by GitHub
parent 24969c87f3
commit 0d512db6e2

View File

@@ -31,10 +31,23 @@ function run (state) {
if (semver.lt(version, '0.21.0')) migrate_0_21_0(saved)
if (semver.lt(version, '0.22.0')) migrate_0_22_0(saved)
if (semver.lt(version, config.APP_VERSION)) {
installHandlers(state.saved)
}
// Config is now on the new version
state.saved.version = config.APP_VERSION
}
// Whenever the app is updated, re-install default handlers if the user has
// enabled them.
function installHandlers (saved) {
if (saved.prefs.isFileHandler) {
const ipcRenderer = require('electron').ipcRenderer
ipcRenderer.send('setDefaultFileHandler', true)
}
}
function migrate_0_7_0 (saved) {
const { copyFileSync } = require('fs')
const path = require('path')