From 3d149eb9d151d72a51bda9721ddfc4d5d341c425 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Dec 2014 09:54:12 -0800 Subject: [PATCH] Only update desktop shortcut if it already exists Delete the created shortcut if it was previously deleted after it was first installed. Closes #4665 --- src/browser/squirrel-update.coffee | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/browser/squirrel-update.coffee b/src/browser/squirrel-update.coffee index dbfc48366..96e28a782 100644 --- a/src/browser/squirrel-update.coffee +++ b/src/browser/squirrel-update.coffee @@ -166,12 +166,27 @@ removeCommandsFromPath = (callback) -> # Create a desktop and start menu shortcut by using the command line API # provided by Squirrel's Update.exe -createShortcut = (callback) -> +createShortcuts = (callback) -> spawnUpdate(['--createShortcut', exeName], callback) +# Update the desktop and start menu shortcuts by using the command line API +# provided by Squirrel's Update.exe +updateShortcuts = (callback) -> + if homeDirectory = fs.getHomeDirectory() + desktopShortcutPath = path.join(homeDirectory, 'Desktop', 'Atom.lnk') + # Check if the desktop shortcut has been previously deleted and + # and keep it deleted if it was + fs.exists desktopShortcutPath, (desktopShortcutExists) -> + createShortcuts -> + return callback() unless desktopShortcutExists + # Remove the unwanted desktop shortcut that was recreated + fs.unlink(desktopShortcutPath, callback) + else + createShortcuts(callback) + # Remove the desktop and start menu shortcuts by using the command line API # provided by Squirrel's Update.exe -removeShortcut = (callback) -> +removeShortcuts = (callback) -> spawnUpdate(['--removeShortcut', exeName], callback) exports.spawn = spawnUpdate @@ -190,14 +205,20 @@ exports.restartAtom = -> # Handle squirrel events denoted by --squirrel-* command line arguments. exports.handleStartupEvent = -> switch process.argv[1] - when '--squirrel-install', '--squirrel-updated' - createShortcut -> + when '--squirrel-install' + createShortcuts -> + installContextMenu -> + addCommandsToPath -> + app.quit() + true + when '--squirrel-updated' + updateShortcuts -> installContextMenu -> addCommandsToPath -> app.quit() true when '--squirrel-uninstall' - removeShortcut -> + removeShortcuts -> uninstallContextMenu -> removeCommandsFromPath -> app.quit()