diff --git a/src/assets.rs b/src/assets.rs index 6350ba0..ba53386 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -35,6 +35,7 @@ pub fn file_from_string(file_path: &str) -> Option<(String, &'static [u8])> { "/index.html", "/favicon.ico", "/logo.png", + "/how-to-open.png", "/css/bulma.min.css", "/css/main.css", "/fonts/roboto-v18-latin-regular.eot", diff --git a/src/http.rs b/src/http.rs index 95f60b5..a0ed427 100644 --- a/src/http.rs +++ b/src/http.rs @@ -9,16 +9,27 @@ use std::time::Duration; use reqwest::Client; +/// Asserts that a URL is valid HTTPS, else returns an error. +pub fn assert_ssl(url: &str) -> Result<(), String> { + if url.starts_with("https://") { + Ok(()) + } else { + Err(format!("Specified URL was not https")) + } +} + /// Builds a customised HTTP client. pub fn build_client() -> Result { Client::builder() .timeout(Duration::from_secs(8)) .build() - .map_err(|x| format!("Unable to build cient: {:?}", x)) + .map_err(|x| format!("Unable to build client: {:?}", x)) } /// Downloads a text file from the specified URL. pub fn download_text(url: &str) -> Result { + assert_ssl(url)?; + let mut client = build_client()? .get(url) .send() @@ -34,6 +45,8 @@ pub fn stream_file(url: &str, mut callback: F) -> Result<(), String> where F: FnMut(Vec, u64) -> (), { + assert_ssl(url)?; + let mut client = build_client()? .get(url) .send() diff --git a/src/logging.rs b/src/logging.rs index 659a52a..e64a9a0 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -7,7 +7,7 @@ use log; use std::fmt::Debug; use std::io; -pub fn setup_logger() -> Result<(), fern::InitError> { +pub fn setup_logger(file_name : String) -> Result<(), fern::InitError> { fern::Dispatch::new() .format(|out, message, record| { out.finish(format_args!( @@ -19,7 +19,7 @@ pub fn setup_logger() -> Result<(), fern::InitError> { )) }).level(log::LevelFilter::Info) .chain(io::stdout()) - .chain(fern::log_file("installer.log")?) + .chain(fern::log_file(file_name)?) .apply()?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index f5b8c9d..b27cee4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,10 +93,10 @@ enum CallbackType { } fn main() { - logging::setup_logger().expect("Unable to setup logging!"); - let config = - BaseAttributes::from_toml_str(RAW_CONFIG).log_expect("Config file could not be read"); + BaseAttributes::from_toml_str(RAW_CONFIG).expect("Config file could not be read"); + + logging::setup_logger(format!("{}_installer.log", config.name)).expect("Unable to setup logging!"); let app_name = config.name.clone(); diff --git a/src/native/mod.rs b/src/native/mod.rs index 160abe4..c16245f 100644 --- a/src/native/mod.rs +++ b/src/native/mod.rs @@ -70,7 +70,7 @@ mod natives { } /// Cleans up the installer - pub fn burn_on_exit() { + pub fn burn_on_exit(app_name : &str) { let current_exe = env::current_exe().log_expect("Current executable could not be found"); let path = current_exe .parent() @@ -83,7 +83,7 @@ mod natives { .log_expect("Unable to convert tool path to string") .replace(" ", "\\ "); - let log = path.join("installer.log"); + let log = path.join(format!("{}_installer.log", app_name)); let log = log .to_str() .log_expect("Unable to convert log path to string") @@ -123,7 +123,7 @@ mod natives { } /// Cleans up the installer - pub fn burn_on_exit() { + pub fn burn_on_exit(app_name : &str) { let current_exe = env::current_exe().log_expect("Current executable could not be found"); // Thank god for *nix platforms @@ -134,7 +134,7 @@ mod natives { let current_dir = env::current_dir().log_expect("Current directory cannot be found"); - if let Err(e) = remove_file(current_dir.join("installer.log")) { + if let Err(e) = remove_file(current_dir.join(format!("{}_installer.log", app_name))) { // No regular logging now. eprintln!("Failed to delete installer log: {:?}", e); }; diff --git a/src/rest.rs b/src/rest.rs index 5e30a45..6d8059a 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -207,7 +207,7 @@ impl Service for WebService { } if framework.burn_after_exit { - native::burn_on_exit(); + native::burn_on_exit(&framework.base_attributes.name); } exit(0); diff --git a/src/tasks/install_global_shortcut.rs b/src/tasks/install_global_shortcut.rs index eeb618e..633324c 100644 --- a/src/tasks/install_global_shortcut.rs +++ b/src/tasks/install_global_shortcut.rs @@ -47,7 +47,7 @@ impl Task for InstallGlobalShortcutsTask { let shortcut_file = create_shortcut( &format!("{} maintenance tool", context.base_attributes.name), &format!( - "Launch the {} maintenance tool to update, modify and uninstall the application.", + "Launch the {} Maintenance Tool to update, modify and uninstall the application.", context.base_attributes.name ), tool_path, diff --git a/static/index.html b/static/index.html index 503182e..7ace508 100644 --- a/static/index.html +++ b/static/index.html @@ -31,7 +31,7 @@

- Welcome to the {{ attrs.name }} maintenance tool. + Welcome to the {{ attrs.name }} Maintenance Tool.

diff --git a/static/js/views.js b/static/js/views.js index 5562b08..ca404c6 100644 --- a/static/js/views.js +++ b/static/js/views.js @@ -343,23 +343,21 @@ const ModifyView = {

Choose an option:

- + + Update + +
+
+ + + Modify + +
+
+ + + Uninstall +