From 1610bcedb1faa4eb40973cace746590c1cb31084 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Sun, 17 Jul 2016 22:42:08 -0700 Subject: [PATCH] Ensure install & upgrade fix up previous shell paths --- src/main-process/squirrel-update.coffee | 32 ++++++++++++++----------- src/main-process/win-shell.coffee | 10 ++++---- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/main-process/squirrel-update.coffee b/src/main-process/squirrel-update.coffee index 5dfff6710..5d9910a19 100644 --- a/src/main-process/squirrel-update.coffee +++ b/src/main-process/squirrel-update.coffee @@ -125,31 +125,35 @@ exports.restartAtom = (app) -> app.once 'will-quit', -> Spawner.spawn(path.join(binFolder, 'atom.cmd'), args) app.quit() +updateContextMenus = (callback) -> + WinShell.fileContextMenu.update -> + WinShell.folderContextMenu.update -> + WinShell.folderBackgroundContextMenu.update -> + callback + # Handle squirrel events denoted by --squirrel-* command line arguments. exports.handleStartupEvent = (app, squirrelCommand) -> switch squirrelCommand when '--squirrel-install' createShortcuts -> - WinShell.fileHandler.register -> - addCommandsToPath -> - app.quit() + addCommandsToPath -> + WinShell.fileHandler.register -> + updateContextMenus -> + app.quit() true when '--squirrel-updated' updateShortcuts -> - WinShell.fileHandler.update -> - WinShell.fileContextMenu.update -> - WinShell.folderContextMenu.update -> - WinShell.folderBackgroundContextMenu.update -> - addCommandsToPath -> - app.quit() + addCommandsToPath -> + updateContextMenus -> + app.quit() true when '--squirrel-uninstall' removeShortcuts -> - WinShell.fileHandler.deregister -> - WinShell.fileContextMenu.deregister -> - WinShell.folderContextMenu.deregister -> - WinShell.folderBackgroundContextMenu.deregister -> - removeCommandsFromPath -> + removeCommandsFromPath -> + WinShell.fileHandler.deregister -> + WinShell.fileContextMenu.deregister -> + WinShell.folderContextMenu.deregister -> + WinShell.folderBackgroundContextMenu.deregister -> app.quit() true when '--squirrel-obsolete' diff --git a/src/main-process/win-shell.coffee b/src/main-process/win-shell.coffee index 5e1e1428a..269e9e97c 100644 --- a/src/main-process/win-shell.coffee +++ b/src/main-process/win-shell.coffee @@ -17,7 +17,7 @@ class ShellOption doneCount = @parts.length @parts.forEach((part) => reg = new Registry({hive: 'HKCU', key: if part.key? then "#{@key}\\#{part.key}" else @key}) - reg.create( -> reg.set part.name, Registry.REG_SZ, part.value, -> callback() if doneCount-- is 0)) + reg.create( -> reg.set part.name, Registry.REG_SZ, part.value, -> callback() if --doneCount is 0)) deregister: (callback) => @isRegistered (isRegistered) => if isRegistered @@ -26,11 +26,11 @@ class ShellOption callback null, false update: (callback) => new Registry({hive: 'HKCU', key: "#{@key}\\#{@parts[0].key}"}) - .get @parts[0].name, (err, val) -> - if err? or not val.value.endsWith '\\' + exeName - callback err, val + .get @parts[0].name, (err, val) => + if err? or not val.value.includes '\\' + exeName + callback(err) else - register callback + @register callback exports.appName = appName