diff --git a/src/frontend/rest/services/authentication.rs b/src/frontend/rest/services/authentication.rs index 269ccf3..193030b 100644 --- a/src/frontend/rest/services/authentication.rs +++ b/src/frontend/rest/services/authentication.rs @@ -190,7 +190,9 @@ pub fn handle(service: &WebService, _req: Request) -> InternalFuture { let req = serde_json::from_slice::(&body); if req.is_err() { warn!("Failed to parse auth request from the frontend"); - return default_future(Response::new().with_status(hyper::StatusCode::BadRequest)); + return default_future( + Response::new().with_status(hyper::StatusCode::BadRequest), + ); } let req = req.unwrap(); diff --git a/src/frontend/rest/services/install.rs b/src/frontend/rest/services/install.rs index f57441a..2b3f3ac 100644 --- a/src/frontend/rest/services/install.rs +++ b/src/frontend/rest/services/install.rs @@ -52,6 +52,19 @@ pub fn handle(service: &WebService, req: Request) -> Future { } } + if !install_desktop_shortcut { + let framework_ref = framework + .read() + .log_expect("InstallerFramework has been dirtied"); + install_desktop_shortcut = framework_ref.preexisting_install + && framework_ref + .database + .packages + .first() + .and_then(|x| Some(x.shortcuts.len() > 1)) + .unwrap_or(false); + } + // The frontend always provides this let path = path.log_expect("No path specified by frontend when one should have already existed"); diff --git a/src/installer.rs b/src/installer.rs index 9eae9ff..1b0bde6 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -36,6 +36,7 @@ use crate::logging::LoggingErrors; use dirs::home_dir; +use std::collections::HashSet; use std::fs::remove_file; use crate::http; @@ -117,7 +118,7 @@ pub struct LocalInstallation { /// Relative paths to generated files pub files: Vec, /// Absolute paths to generated shortcut files - pub shortcuts: Vec, + pub shortcuts: HashSet, } macro_rules! declare_messenger_callback { diff --git a/src/tasks/install_desktop_shortcut.rs b/src/tasks/install_desktop_shortcut.rs index 2bb56bc..6711a5b 100644 --- a/src/tasks/install_desktop_shortcut.rs +++ b/src/tasks/install_desktop_shortcut.rs @@ -11,6 +11,7 @@ use crate::config::PackageDescription; use crate::logging::LoggingErrors; +#[cfg(windows)] use crate::native::create_desktop_shortcut; pub struct InstallDesktopShortcutTask { @@ -84,6 +85,7 @@ impl Task for InstallDesktopShortcutTask { .to_str() .log_expect("Unable to build shortcut metadata (exe)"); + #[cfg(windows)] installed_files.push(create_desktop_shortcut( &shortcut.name, &shortcut.description, @@ -99,7 +101,7 @@ impl Task for InstallDesktopShortcutTask { let packages = &mut context.database.packages; for pack in packages { if pack.name == self.name { - pack.shortcuts.append(&mut installed_files); + pack.shortcuts.extend(installed_files.clone()); } } diff --git a/src/tasks/install_pkg.rs b/src/tasks/install_pkg.rs index 79a7ea3..2551500 100644 --- a/src/tasks/install_pkg.rs +++ b/src/tasks/install_pkg.rs @@ -23,6 +23,7 @@ use crate::logging::LoggingErrors; use crate::archives; use crate::tasks::install_desktop_shortcut::InstallDesktopShortcutTask; +use std::collections::HashSet; use std::fs::OpenOptions; use std::path::Path; @@ -172,7 +173,7 @@ impl Task for InstallPackageTask { context.database.packages.push(LocalInstallation { name: package.name, version, - shortcuts: Vec::new(), + shortcuts: HashSet::new(), files: installed_files, }); diff --git a/src/tasks/install_shortcuts.rs b/src/tasks/install_shortcuts.rs index b26aa6e..5b7f370 100644 --- a/src/tasks/install_shortcuts.rs +++ b/src/tasks/install_shortcuts.rs @@ -91,7 +91,7 @@ impl Task for InstallShortcutsTask { let packages = &mut context.database.packages; for pack in packages { if pack.name == self.name { - pack.shortcuts.append(&mut installed_files); + pack.shortcuts.extend(installed_files.clone()); } }