diff --git a/src/Rust/src/platform/windows/shortcuts.rs b/src/Rust/src/platform/windows/shortcuts.rs index 72f2cd4a..6aee594f 100644 --- a/src/Rust/src/platform/windows/shortcuts.rs +++ b/src/Rust/src/platform/windows/shortcuts.rs @@ -32,14 +32,14 @@ fn _resolve_lnk(link_path: &str) -> Result<(String, String)> { let flags_with_timeout = co::SLR::ANY_MATCH | co::SLR::NO_UI | unsafe { co::SLR::from_raw(1 << 16) }; if let Err(e) = me.Resolve(&w::HWND::NULL, flags_with_timeout) { // this happens if the target path is missing and the link is broken - error!("Failed to resolve link: {:?}", e); + warn!("Failed to resolve link {} ({:?})", link_path, e); } let path = me.GetPath(None, co::SLGP::UNCPRIORITY)?; let workdir = me.GetWorkingDirectory()?; Ok((path, workdir)) } -pub fn remove_all_for_root_dir>(root_dir: P) -> Result<()> { +pub fn remove_all_shortcuts_for_root_dir>(root_dir: P) -> Result<()> { let _comguard = w::CoInitializeEx(co::COINIT::APARTMENTTHREADED)?; let root_dir = root_dir.as_ref(); info!("Searching for shortcuts containing root: '{}'", root_dir.to_string_lossy()); @@ -108,7 +108,7 @@ fn shortcut_full_integration_test() { assert_eq!(target_out, target); assert_eq!(work_out, work); - remove_all_for_root_dir(root).unwrap(); + remove_all_shortcuts_for_root_dir(root).unwrap(); assert!(!link_location.exists()); } diff --git a/src/Rust/src/setup.rs b/src/Rust/src/setup.rs index 8d85bce5..81992c5a 100644 --- a/src/Rust/src/setup.rs +++ b/src/Rust/src/setup.rs @@ -324,10 +324,11 @@ fn install_app(pkg: &bundle::BundleInfo, root_path: &PathBuf, tx: &std::sync::mp } info!("Creating start menu shortcut..."); - let _comguard = w::CoInitializeEx(co::COINIT::APARTMENTTHREADED)?; let startmenu = w::SHGetKnownFolderPath(&co::KNOWNFOLDERID::StartMenu, co::KF::DONT_UNEXPAND, None)?; let lnk_path = Path::new(&startmenu).join("Programs").join(format!("{}.lnk", &app.title)); - platform::create_lnk(&lnk_path.to_string_lossy(), &main_exe_path, ¤t_path)?; + if let Err(e) = platform::create_lnk(&lnk_path.to_string_lossy(), &main_exe_path, ¤t_path) { + warn!("Failed to create start menu shortcut: {}", e); + } info!("Starting process install hook: \"{}\" --squirrel-install {}", main_exe_path, &app.version); let args = vec!["--squirrel-install", &app.version]; diff --git a/src/Rust/src/update.rs b/src/Rust/src/update.rs index cd31a2fa..dde6fa36 100644 --- a/src/Rust/src/update.rs +++ b/src/Rust/src/update.rs @@ -203,17 +203,17 @@ fn uninstall(_matches: &ArgMatches, log_file: &PathBuf) -> Result<()> { // in case the uninstall hook left running processes let _ = platform::kill_processes_in_directory(&root_path); + if let Err(e) = platform::remove_all_shortcuts_for_root_dir(&root_path) { + error!("Unable to remove shortcuts ({}).", e); + // finished_with_errors = true; + } + info!("Removing directory '{}'", root_path.to_string_lossy()); if let Err(e) = util::retry_io(|| remove_dir_all::remove_dir_containing_current_executable()) { error!("Unable to remove directory, some files may be in use ({}).", e); finished_with_errors = true; } - if let Err(e) = platform::remove_all_for_root_dir(&root_path) { - error!("Unable to remove shortcuts ({}).", e); - // finished_with_errors = true; - } - if let Err(e) = app.remove_uninstall_entry() { error!("Unable to remove uninstall registry entry ({}).", e); // finished_with_errors = true;