mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-26 04:35:37 +01:00
Delete the maintenance tool binary itself after uninstall (closes #1)
This commit is contained in:
parent
19bec5d80c
commit
3ff35b2e62
@ -63,6 +63,8 @@ pub struct InstallerFramework {
|
|||||||
pub install_path: Option<PathBuf>,
|
pub install_path: Option<PathBuf>,
|
||||||
pub preexisting_install: bool,
|
pub preexisting_install: bool,
|
||||||
pub is_launcher: bool,
|
pub is_launcher: bool,
|
||||||
|
// If we just completed an uninstall, and we should clean up after ourselves.
|
||||||
|
pub burn_after_exit: bool,
|
||||||
pub launcher_path: Option<String>,
|
pub launcher_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +201,7 @@ impl InstallerFramework {
|
|||||||
.map_err(|x| format!("Failed to delete metadata: {:?}", x))?;
|
.map_err(|x| format!("Failed to delete metadata: {:?}", x))?;
|
||||||
|
|
||||||
// Logging will have to be done later
|
// Logging will have to be done later
|
||||||
|
self.burn_after_exit = true;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -254,6 +257,7 @@ impl InstallerFramework {
|
|||||||
install_path: None,
|
install_path: None,
|
||||||
preexisting_install: false,
|
preexisting_install: false,
|
||||||
is_launcher: false,
|
is_launcher: false,
|
||||||
|
burn_after_exit: false,
|
||||||
launcher_path: None,
|
launcher_path: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,6 +284,7 @@ impl InstallerFramework {
|
|||||||
install_path: Some(path),
|
install_path: Some(path),
|
||||||
preexisting_install: true,
|
preexisting_install: true,
|
||||||
is_launcher: false,
|
is_launcher: false,
|
||||||
|
burn_after_exit: false,
|
||||||
launcher_path: None,
|
launcher_path: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ mod natives {
|
|||||||
use logging::LoggingErrors;
|
use logging::LoggingErrors;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/interop.rs"));
|
include!(concat!(env!("OUT_DIR"), "/interop.rs"));
|
||||||
|
|
||||||
@ -59,10 +61,39 @@ mod natives {
|
|||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cleans up the installer
|
||||||
|
pub fn burn_on_exit(path: PathBuf) {
|
||||||
|
// Need a cmd workaround here.
|
||||||
|
let tool = path.join("maintenancetool.exe");
|
||||||
|
let tool = tool
|
||||||
|
.to_str()
|
||||||
|
.log_expect("Unable to convert tool path to string")
|
||||||
|
.replace(" ", "\\ ");
|
||||||
|
|
||||||
|
let log = path.join("installer.log");
|
||||||
|
let log = log
|
||||||
|
.to_str()
|
||||||
|
.log_expect("Unable to convert log path to string")
|
||||||
|
.replace(" ", "\\ ");
|
||||||
|
|
||||||
|
let target_arguments = format!("ping 127.0.0.1 -n 6 > nul && del {} {}", tool, log);
|
||||||
|
|
||||||
|
info!("Launching cmd with {:?}", target_arguments);
|
||||||
|
|
||||||
|
Command::new("C:\\Windows\\system32\\cmd.exe")
|
||||||
|
.arg("/C")
|
||||||
|
.arg(&target_arguments)
|
||||||
|
.spawn()
|
||||||
|
.log_expect("Unable to start child process");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
mod natives {
|
mod natives {
|
||||||
|
use std::fs::remove_file;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn create_shortcut(
|
pub fn create_shortcut(
|
||||||
name: &str,
|
name: &str,
|
||||||
description: &str,
|
description: &str,
|
||||||
@ -75,6 +106,20 @@ mod natives {
|
|||||||
|
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cleans up the installer
|
||||||
|
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.
|
||||||
|
eprintln!("Failed to delete maintenancetool: {:?}", e);
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = remove_file(path.join("/installer.log")) {
|
||||||
|
// No regular logging now.
|
||||||
|
eprintln!("Failed to delete installer log: {:?}", e);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use self::natives::*;
|
pub use self::natives::*;
|
||||||
|
14
src/rest.rs
14
src/rest.rs
@ -19,6 +19,7 @@ use url::form_urlencoded;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use std::process::Command;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
@ -30,12 +31,13 @@ use installer::InstallMessage;
|
|||||||
use installer::InstallerFramework;
|
use installer::InstallerFramework;
|
||||||
|
|
||||||
use logging::LoggingErrors;
|
use logging::LoggingErrors;
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use http;
|
use http;
|
||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
||||||
|
use native;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct FileSelection {
|
struct FileSelection {
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
@ -204,6 +206,16 @@ impl Service for WebService {
|
|||||||
.log_expect("Unable to start child process");
|
.log_expect("Unable to start child process");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if framework.burn_after_exit {
|
||||||
|
let path = framework
|
||||||
|
.install_path
|
||||||
|
.clone()
|
||||||
|
.log_expect("No install path when one should have existed?");
|
||||||
|
|
||||||
|
println!("Base path: {:?}", path);
|
||||||
|
native::burn_on_exit(path);
|
||||||
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
// Gets properties such as if the application is in maintenance mode
|
// Gets properties such as if the application is in maintenance mode
|
||||||
|
Loading…
Reference in New Issue
Block a user