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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ impl Task for UninstallGlobalShortcutsTask {
) -> Result<TaskParamType, String> {
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() {
info!("Deleting shortcut {:?}", file);