mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 13:05:40 +01:00
Minor QoL tweaks
This commit is contained in:
parent
36179dcf82
commit
245ea31297
@ -35,6 +35,7 @@ pub fn file_from_string(file_path: &str) -> Option<(String, &'static [u8])> {
|
|||||||
"/index.html",
|
"/index.html",
|
||||||
"/favicon.ico",
|
"/favicon.ico",
|
||||||
"/logo.png",
|
"/logo.png",
|
||||||
|
"/how-to-open.png",
|
||||||
"/css/bulma.min.css",
|
"/css/bulma.min.css",
|
||||||
"/css/main.css",
|
"/css/main.css",
|
||||||
"/fonts/roboto-v18-latin-regular.eot",
|
"/fonts/roboto-v18-latin-regular.eot",
|
||||||
|
15
src/http.rs
15
src/http.rs
@ -9,16 +9,27 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use reqwest::Client;
|
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.
|
/// Builds a customised HTTP client.
|
||||||
pub fn build_client() -> Result<Client, String> {
|
pub fn build_client() -> Result<Client, String> {
|
||||||
Client::builder()
|
Client::builder()
|
||||||
.timeout(Duration::from_secs(8))
|
.timeout(Duration::from_secs(8))
|
||||||
.build()
|
.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.
|
/// Downloads a text file from the specified URL.
|
||||||
pub fn download_text(url: &str) -> Result<String, String> {
|
pub fn download_text(url: &str) -> Result<String, String> {
|
||||||
|
assert_ssl(url)?;
|
||||||
|
|
||||||
let mut client = build_client()?
|
let mut client = build_client()?
|
||||||
.get(url)
|
.get(url)
|
||||||
.send()
|
.send()
|
||||||
@ -34,6 +45,8 @@ pub fn stream_file<F>(url: &str, mut callback: F) -> Result<(), String>
|
|||||||
where
|
where
|
||||||
F: FnMut(Vec<u8>, u64) -> (),
|
F: FnMut(Vec<u8>, u64) -> (),
|
||||||
{
|
{
|
||||||
|
assert_ssl(url)?;
|
||||||
|
|
||||||
let mut client = build_client()?
|
let mut client = build_client()?
|
||||||
.get(url)
|
.get(url)
|
||||||
.send()
|
.send()
|
||||||
|
@ -7,7 +7,7 @@ use log;
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
pub fn setup_logger() -> Result<(), fern::InitError> {
|
pub fn setup_logger(file_name : String) -> Result<(), fern::InitError> {
|
||||||
fern::Dispatch::new()
|
fern::Dispatch::new()
|
||||||
.format(|out, message, record| {
|
.format(|out, message, record| {
|
||||||
out.finish(format_args!(
|
out.finish(format_args!(
|
||||||
@ -19,7 +19,7 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
|
|||||||
))
|
))
|
||||||
}).level(log::LevelFilter::Info)
|
}).level(log::LevelFilter::Info)
|
||||||
.chain(io::stdout())
|
.chain(io::stdout())
|
||||||
.chain(fern::log_file("installer.log")?)
|
.chain(fern::log_file(file_name)?)
|
||||||
.apply()?;
|
.apply()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,10 @@ enum CallbackType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logging::setup_logger().expect("Unable to setup logging!");
|
|
||||||
|
|
||||||
let config =
|
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();
|
let app_name = config.name.clone();
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ mod natives {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Cleans up the installer
|
/// 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 current_exe = env::current_exe().log_expect("Current executable could not be found");
|
||||||
let path = current_exe
|
let path = current_exe
|
||||||
.parent()
|
.parent()
|
||||||
@ -83,7 +83,7 @@ mod natives {
|
|||||||
.log_expect("Unable to convert tool path to string")
|
.log_expect("Unable to convert tool path to string")
|
||||||
.replace(" ", "\\ ");
|
.replace(" ", "\\ ");
|
||||||
|
|
||||||
let log = path.join("installer.log");
|
let log = path.join(format!("{}_installer.log", app_name));
|
||||||
let log = log
|
let log = log
|
||||||
.to_str()
|
.to_str()
|
||||||
.log_expect("Unable to convert log path to string")
|
.log_expect("Unable to convert log path to string")
|
||||||
@ -123,7 +123,7 @@ mod natives {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Cleans up the installer
|
/// 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 current_exe = env::current_exe().log_expect("Current executable could not be found");
|
||||||
|
|
||||||
// Thank god for *nix platforms
|
// Thank god for *nix platforms
|
||||||
@ -134,7 +134,7 @@ mod natives {
|
|||||||
|
|
||||||
let current_dir = env::current_dir().log_expect("Current directory cannot be found");
|
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.
|
// No regular logging now.
|
||||||
eprintln!("Failed to delete installer log: {:?}", e);
|
eprintln!("Failed to delete installer log: {:?}", e);
|
||||||
};
|
};
|
||||||
|
@ -207,7 +207,7 @@ impl Service for WebService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if framework.burn_after_exit {
|
if framework.burn_after_exit {
|
||||||
native::burn_on_exit();
|
native::burn_on_exit(&framework.base_attributes.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -47,7 +47,7 @@ impl Task for InstallGlobalShortcutsTask {
|
|||||||
let shortcut_file = 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.",
|
||||||
context.base_attributes.name
|
context.base_attributes.name
|
||||||
),
|
),
|
||||||
tool_path,
|
tool_path,
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<h2 class="subtitle" v-if="metadata.preexisting_install">
|
<h2 class="subtitle" v-if="metadata.preexisting_install">
|
||||||
Welcome to the {{ attrs.name }} maintenance tool.
|
Welcome to the {{ attrs.name }} Maintenance Tool.
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -343,23 +343,21 @@ const ModifyView = {
|
|||||||
<div class="column has-padding">
|
<div class="column has-padding">
|
||||||
<h4 class="subtitle">Choose an option:</h4>
|
<h4 class="subtitle">Choose an option:</h4>
|
||||||
|
|
||||||
<div class="field is-grouped is-bottom-floating">
|
<a class="button is-dark is-medium" v-on:click="update">
|
||||||
<p class="control">
|
Update
|
||||||
<a class="button is-link is-medium" v-on:click="update">
|
</a>
|
||||||
Update
|
<br />
|
||||||
</a>
|
<br />
|
||||||
</p>
|
|
||||||
<p class="control">
|
<a class="button is-dark is-medium" v-on:click="modify_packages">
|
||||||
<a class="button is-medium" v-on:click="modify_packages">
|
Modify
|
||||||
Modify
|
</a>
|
||||||
</a>
|
<br />
|
||||||
</p>
|
<br />
|
||||||
<p class="control">
|
|
||||||
<a class="button is-danger is-medium" v-on:click="prepare_uninstall">
|
<a class="button is-dark is-medium" v-on:click="prepare_uninstall">
|
||||||
Uninstall
|
Uninstall
|
||||||
</a>
|
</a>
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal is-active" v-if="show_uninstall">
|
<div class="modal is-active" v-if="show_uninstall">
|
||||||
<div class="modal-background"></div>
|
<div class="modal-background"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user