mirror of
				https://github.com/velopack/velopack.git
				synced 2025-10-25 15:19:22 +00:00 
			
		
		
		
	Shortcut failing to create, duplicate com guard
This commit is contained in:
		| @@ -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) }; |     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) { |     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 |         // 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 path = me.GetPath(None, co::SLGP::UNCPRIORITY)?; | ||||||
|     let workdir = me.GetWorkingDirectory()?; |     let workdir = me.GetWorkingDirectory()?; | ||||||
|     Ok((path, workdir)) |     Ok((path, workdir)) | ||||||
| } | } | ||||||
|  |  | ||||||
| pub fn remove_all_for_root_dir<P: AsRef<Path>>(root_dir: P) -> Result<()> { | pub fn remove_all_shortcuts_for_root_dir<P: AsRef<Path>>(root_dir: P) -> Result<()> { | ||||||
|     let _comguard = w::CoInitializeEx(co::COINIT::APARTMENTTHREADED)?; |     let _comguard = w::CoInitializeEx(co::COINIT::APARTMENTTHREADED)?; | ||||||
|     let root_dir = root_dir.as_ref(); |     let root_dir = root_dir.as_ref(); | ||||||
|     info!("Searching for shortcuts containing root: '{}'", root_dir.to_string_lossy()); |     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!(target_out, target); | ||||||
|     assert_eq!(work_out, work); |     assert_eq!(work_out, work); | ||||||
|  |  | ||||||
|     remove_all_for_root_dir(root).unwrap(); |     remove_all_shortcuts_for_root_dir(root).unwrap(); | ||||||
|     assert!(!link_location.exists()); |     assert!(!link_location.exists()); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -324,10 +324,11 @@ fn install_app(pkg: &bundle::BundleInfo, root_path: &PathBuf, tx: &std::sync::mp | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     info!("Creating start menu shortcut..."); |     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 startmenu = w::SHGetKnownFolderPath(&co::KNOWNFOLDERID::StartMenu, co::KF::DONT_UNEXPAND, None)?; | ||||||
|     let lnk_path = Path::new(&startmenu).join("Programs").join(format!("{}.lnk", &app.title)); |     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); |     info!("Starting process install hook: \"{}\" --squirrel-install {}", main_exe_path, &app.version); | ||||||
|     let args = vec!["--squirrel-install", &app.version]; |     let args = vec!["--squirrel-install", &app.version]; | ||||||
|   | |||||||
| @@ -203,17 +203,17 @@ fn uninstall(_matches: &ArgMatches, log_file: &PathBuf) -> Result<()> { | |||||||
|         // in case the uninstall hook left running processes |         // in case the uninstall hook left running processes | ||||||
|         let _ = platform::kill_processes_in_directory(&root_path); |         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()); |         info!("Removing directory '{}'", root_path.to_string_lossy()); | ||||||
|         if let Err(e) = util::retry_io(|| remove_dir_all::remove_dir_containing_current_executable()) { |         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); |             error!("Unable to remove directory, some files may be in use ({}).", e); | ||||||
|             finished_with_errors = true; |             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() { |         if let Err(e) = app.remove_uninstall_entry() { | ||||||
|             error!("Unable to remove uninstall registry entry ({}).", e); |             error!("Unable to remove uninstall registry entry ({}).", e); | ||||||
|             // finished_with_errors = true; |             // finished_with_errors = true; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user