Clean up wasted allocations in shortcut generation

This commit is contained in:
James 2018-08-08 20:29:59 +10:00
parent 3ff35b2e62
commit 9acd9f69f3
4 changed files with 11 additions and 7 deletions

View file

@ -63,7 +63,7 @@ mod natives {
} }
/// Cleans up the installer /// Cleans up the installer
pub fn burn_on_exit(path: PathBuf) { pub fn burn_on_exit(path: &PathBuf) {
// Need a cmd workaround here. // Need a cmd workaround here.
let tool = path.join("maintenancetool.exe"); let tool = path.join("maintenancetool.exe");
let tool = tool let tool = tool
@ -108,7 +108,7 @@ mod natives {
} }
/// Cleans up the installer /// Cleans up the installer
pub fn burn_on_exit(path: PathBuf) { pub fn burn_on_exit(path: &PathBuf) {
// Thank god for *nix platforms // Thank god for *nix platforms
if let Err(e) = remove_file(path.join("/maintenancetool")) { if let Err(e) = remove_file(path.join("/maintenancetool")) {
// No regular logging now. // No regular logging now.

View file

@ -209,7 +209,7 @@ impl Service for WebService {
if framework.burn_after_exit { if framework.burn_after_exit {
let path = framework let path = framework
.install_path .install_path
.clone() .as_ref()
.log_expect("No install path when one should have existed?"); .log_expect("No install path when one should have existed?");
println!("Base path: {:?}", path); println!("Base path: {:?}", path);

View file

@ -21,7 +21,7 @@ impl Task for InstallGlobalShortcutsTask {
context: &mut InstallerFramework, context: &mut InstallerFramework,
messenger: &Fn(&str, f64), messenger: &Fn(&str, f64),
) -> Result<TaskParamType, String> { ) -> Result<TaskParamType, String> {
messenger(&format!("Generating global shortcut..."), 0.0); messenger("Generating global shortcut...", 0.0);
let path = context let path = context
.install_path .install_path
@ -44,7 +44,7 @@ impl Task for InstallGlobalShortcutsTask {
.to_str() .to_str()
.log_expect("Unable to build shortcut metadata (tool)"); .log_expect("Unable to build shortcut metadata (tool)");
context.database.shortcuts.push(create_shortcut( let shortcut_file = create_shortcut(
&format!("{} maintenance tool", context.base_attributes.name), &format!("{} maintenance tool", context.base_attributes.name),
&format!( &format!(
"Launch the {} maintenance tool to update, modify and uninstall the application.", "Launch the {} maintenance tool to update, modify and uninstall the application.",
@ -54,7 +54,11 @@ impl Task for InstallGlobalShortcutsTask {
// TODO: Send by list // TODO: Send by list
"", "",
&starting_dir, &starting_dir,
)?); )?;
if !shortcut_file.is_empty() {
context.database.shortcuts.push(shortcut_file);
}
Ok(TaskParamType::None) Ok(TaskParamType::None)
} }

View file

@ -21,7 +21,7 @@ impl Task for UninstallGlobalShortcutsTask {
) -> Result<TaskParamType, String> { ) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0); assert_eq!(input.len(), 0);
messenger(&format!("Uninstalling global shortcut..."), 0.0); messenger("Uninstalling global shortcut...", 0.0);
while let Some(file) = context.database.shortcuts.pop() { while let Some(file) = context.database.shortcuts.pop() {
info!("Deleting shortcut {:?}", file); info!("Deleting shortcut {:?}", file);