mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-12-22 08:55:34 +00:00
tree-wide: format code
This commit is contained in:
parent
9a27b24f05
commit
d269677b2c
4
build.rs
4
build.rs
|
@ -105,7 +105,9 @@ fn main() {
|
|||
// bundle the icon
|
||||
let mut f = File::create(output_dir.join("icon-data.bin")).unwrap();
|
||||
let icon_file = image::open("ui/public/favicon.ico").expect("Unable to read the icon file");
|
||||
let icon_data = icon_file.resize_exact(48, 48, FilterType::Triangle).to_rgba8();
|
||||
let icon_data = icon_file
|
||||
.resize_exact(48, 48, FilterType::Triangle)
|
||||
.to_rgba8();
|
||||
f.write_all(&icon_data.into_vec()).unwrap();
|
||||
|
||||
// Build and deploy frontend files
|
||||
|
|
|
@ -130,8 +130,12 @@ pub fn validate_token(
|
|||
let pub_key = if pub_key_base64.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
base64::decode(&pub_key_base64)
|
||||
.map_err(|e| format!("Configured public key was not empty and did not decode as base64 {:?}", e))?
|
||||
base64::decode(&pub_key_base64).map_err(|e| {
|
||||
format!(
|
||||
"Configured public key was not empty and did not decode as base64 {:?}",
|
||||
e
|
||||
)
|
||||
})?
|
||||
};
|
||||
|
||||
// Configure validation for audience and issuer if the configuration provides it
|
||||
|
|
|
@ -23,13 +23,13 @@ pub fn handle(service: &WebService, req: Request) -> Future {
|
|||
|
||||
Box::new(req.body().concat2().map(move |b| {
|
||||
let results = form_urlencoded::parse(b.as_ref())
|
||||
.into_owned()
|
||||
.collect::<HashMap<String, String>>();
|
||||
|
||||
.into_owned()
|
||||
.collect::<HashMap<String, String>>();
|
||||
|
||||
let mut to_install = Vec::new();
|
||||
let mut path: Option<String> = None;
|
||||
let mut force_install = false;
|
||||
let mut install_desktop_shortcut= false;
|
||||
let mut install_desktop_shortcut = false;
|
||||
|
||||
// Transform results into just an array of stuff to install
|
||||
for (key, value) in &results {
|
||||
|
@ -66,7 +66,13 @@ pub fn handle(service: &WebService, req: Request) -> Future {
|
|||
framework.set_install_dir(&path);
|
||||
}
|
||||
|
||||
if let Err(v) = framework.install(to_install, &sender, new_install, install_desktop_shortcut, force_install) {
|
||||
if let Err(v) = framework.install(
|
||||
to_install,
|
||||
&sender,
|
||||
new_install,
|
||||
install_desktop_shortcut,
|
||||
force_install,
|
||||
) {
|
||||
error!("Install error occurred: {:?}", v);
|
||||
if let Err(v) = sender.send(InstallMessage::Error(v)) {
|
||||
error!("Failed to send install error: {:?}", v);
|
||||
|
|
|
@ -18,7 +18,6 @@ use crate::logging::LoggingErrors;
|
|||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
/// Struct used by serde to send a JSON payload to the client containing an optional value.
|
||||
#[derive(Serialize)]
|
||||
struct VerifyResponse {
|
||||
|
@ -28,8 +27,8 @@ struct VerifyResponse {
|
|||
pub fn handle(_service: &WebService, req: Request) -> Future {
|
||||
Box::new(req.body().concat2().map(move |b| {
|
||||
let results = form_urlencoded::parse(b.as_ref())
|
||||
.into_owned()
|
||||
.collect::<HashMap<String, String>>();
|
||||
.into_owned()
|
||||
.collect::<HashMap<String, String>>();
|
||||
let mut exists = false;
|
||||
if let Some(path) = results.get("path") {
|
||||
let path = PathBuf::from(path);
|
||||
|
@ -37,10 +36,10 @@ pub fn handle(_service: &WebService, req: Request) -> Future {
|
|||
}
|
||||
|
||||
let response = VerifyResponse { exists };
|
||||
|
||||
|
||||
let file = serde_json::to_string(&response)
|
||||
.log_expect("Failed to render JSON payload of default path object");
|
||||
|
||||
|
||||
Response::new()
|
||||
.with_header(ContentLength(file.len() as u64))
|
||||
.with_header(ContentType::json())
|
||||
|
|
|
@ -8,7 +8,7 @@ use wry::{
|
|||
dpi::LogicalSize,
|
||||
event::{Event, StartCause, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{WindowBuilder, Icon},
|
||||
window::{Icon, WindowBuilder},
|
||||
},
|
||||
webview::{RpcResponse, WebViewBuilder},
|
||||
};
|
||||
|
@ -32,7 +32,8 @@ pub fn start_ui(app_name: &str, http_address: &str, is_launcher: bool) -> Result
|
|||
};
|
||||
info!("Spawning web view instance");
|
||||
|
||||
let window_icon = Icon::from_rgba(ICON_DATA.to_vec(), 48, 48).log_expect("Unable to construct window icon");
|
||||
let window_icon =
|
||||
Icon::from_rgba(ICON_DATA.to_vec(), 48, 48).log_expect("Unable to construct window icon");
|
||||
let event_loop = EventLoop::new();
|
||||
let window = WindowBuilder::new()
|
||||
.with_title(format!("{} Installer", app_name))
|
||||
|
|
|
@ -211,7 +211,7 @@ impl InstallerFramework {
|
|||
uninstall_items,
|
||||
fresh_install,
|
||||
create_desktop_shortcuts,
|
||||
force_install
|
||||
force_install,
|
||||
});
|
||||
|
||||
let mut tree = DependencyTree::build(task);
|
||||
|
|
|
@ -200,10 +200,16 @@ mod natives {
|
|||
.to_str()
|
||||
.log_expect("Unable to convert log path to string")
|
||||
.replace(" ", "\\ ");
|
||||
|
||||
let install_path = path.to_str().log_expect("Unable to convert path to string").replace(" ", "\\ ");
|
||||
|
||||
let target_arguments = format!("/C choice /C Y /N /D Y /T 2 & del {} {} & rmdir {}", tool, log, install_path);
|
||||
let install_path = path
|
||||
.to_str()
|
||||
.log_expect("Unable to convert path to string")
|
||||
.replace(" ", "\\ ");
|
||||
|
||||
let target_arguments = format!(
|
||||
"/C choice /C Y /N /D Y /T 2 & del {} {} & rmdir {}",
|
||||
tool, log, install_path
|
||||
);
|
||||
|
||||
info!("Launching cmd with {:?}", target_arguments);
|
||||
|
||||
|
@ -333,13 +339,13 @@ mod natives {
|
|||
|
||||
#[cfg(not(windows))]
|
||||
mod natives {
|
||||
use std::fs::{remove_file, remove_dir};
|
||||
use std::fs::{remove_dir, remove_file};
|
||||
|
||||
use std::env;
|
||||
|
||||
use crate::logging::LoggingErrors;
|
||||
|
||||
use sysinfo::{ProcessExt, SystemExt, PidExt};
|
||||
use sysinfo::{PidExt, ProcessExt, SystemExt};
|
||||
|
||||
use dirs;
|
||||
|
||||
|
@ -423,7 +429,9 @@ mod natives {
|
|||
/// Cleans up the installer
|
||||
pub fn burn_on_exit(app_name: &str) {
|
||||
let current_exe = env::current_exe().log_expect("Current executable could not be found");
|
||||
let exe_dir = current_exe.parent().log_expect("Current executable directory cannot be found");
|
||||
let exe_dir = current_exe
|
||||
.parent()
|
||||
.log_expect("Current executable directory cannot be found");
|
||||
|
||||
if let Err(e) = remove_file(exe_dir.join(format!("{}_installer.log", app_name))) {
|
||||
// No regular logging now.
|
||||
|
|
|
@ -23,9 +23,7 @@ impl Version {
|
|||
fn coarse_into_semver(&self) -> SemverVersion {
|
||||
match *self {
|
||||
Version::Semver(ref version) => version.to_owned(),
|
||||
Version::Integer(ref version) => {
|
||||
SemverVersion::new(version.to_owned(), 0u64, 0u64)
|
||||
}
|
||||
Version::Integer(ref version) => SemverVersion::new(version.to_owned(), 0u64, 0u64),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ impl Task for CheckAuthorizationTask {
|
|||
) -> Result<TaskParamType, String> {
|
||||
assert_eq!(input.len(), 1);
|
||||
|
||||
let params = input.pop().log_expect("Check Authorization Task should have input from resolver!");
|
||||
let params = input
|
||||
.pop()
|
||||
.log_expect("Check Authorization Task should have input from resolver!");
|
||||
let (version, file) = match params {
|
||||
TaskParamType::File(v, f) => Ok((v, f)),
|
||||
_ => Err("Unexpected TaskParamType in CheckAuthorization: {:?}"),
|
||||
|
|
|
@ -28,7 +28,9 @@ impl Task for DownloadPackageTask {
|
|||
) -> Result<TaskParamType, String> {
|
||||
assert_eq!(input.len(), 1);
|
||||
|
||||
let file = input.pop().log_expect("Download Package Task should have input from resolver!");
|
||||
let file = input
|
||||
.pop()
|
||||
.log_expect("Download Package Task should have input from resolver!");
|
||||
let (version, file, auth) = match file {
|
||||
TaskParamType::Authentication(v, f, auth) => (v, f, auth),
|
||||
_ => return Err("Unexpected param type to download package".to_string()),
|
||||
|
|
|
@ -6,10 +6,10 @@ use crate::tasks::ensure_only_instance::EnsureOnlyInstanceTask;
|
|||
use crate::tasks::install_dir::VerifyInstallDirTask;
|
||||
use crate::tasks::install_global_shortcut::InstallGlobalShortcutsTask;
|
||||
use crate::tasks::install_pkg::InstallPackageTask;
|
||||
use crate::tasks::launch_installed_on_exit::LaunchOnExitTask;
|
||||
use crate::tasks::remove_target_dir::RemoveTargetDirTask;
|
||||
use crate::tasks::save_executable::SaveExecutableTask;
|
||||
use crate::tasks::uninstall_pkg::UninstallPackageTask;
|
||||
use crate::tasks::launch_installed_on_exit::LaunchOnExitTask;
|
||||
|
||||
use crate::tasks::Task;
|
||||
use crate::tasks::TaskDependency;
|
||||
|
@ -72,7 +72,10 @@ impl Task for InstallTask {
|
|||
for item in &self.items {
|
||||
elements.push(TaskDependency::build(
|
||||
TaskOrdering::Pre,
|
||||
Box::new(InstallPackageTask { name: item.clone(), create_desktop_shortcuts: self.create_desktop_shortcuts }),
|
||||
Box::new(InstallPackageTask {
|
||||
name: item.clone(),
|
||||
create_desktop_shortcuts: self.create_desktop_shortcuts,
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -89,7 +92,7 @@ impl Task for InstallTask {
|
|||
|
||||
elements.push(TaskDependency::build(
|
||||
TaskOrdering::Post,
|
||||
Box::new(LaunchOnExitTask {})
|
||||
Box::new(LaunchOnExitTask {}),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ impl Task for InstallDesktopShortcutTask {
|
|||
}
|
||||
|
||||
messenger(&TaskMessage::DisplayMessage(
|
||||
&format!("Generating desktop shortcuts for package {:?}...", self.name),
|
||||
&format!(
|
||||
"Generating desktop shortcuts for package {:?}...",
|
||||
self.name
|
||||
),
|
||||
0.0,
|
||||
));
|
||||
|
||||
|
@ -51,12 +54,12 @@ impl Task for InstallDesktopShortcutTask {
|
|||
.as_ref()
|
||||
.log_expect("Should have packages by now")
|
||||
.packages
|
||||
{
|
||||
if self.name == description.name {
|
||||
metadata = Some(description.clone());
|
||||
break;
|
||||
}
|
||||
{
|
||||
if self.name == description.name {
|
||||
metadata = Some(description.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let package = match metadata {
|
||||
Some(v) => v,
|
||||
|
@ -108,6 +111,9 @@ impl Task for InstallDesktopShortcutTask {
|
|||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
format!("InstallDesktopShortcutTask (for {:?}, should_run = {:?})", self.name, self.should_run)
|
||||
format!(
|
||||
"InstallDesktopShortcutTask (for {:?}, should_run = {:?})",
|
||||
self.name, self.should_run
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use crate::logging::LoggingErrors;
|
|||
pub struct LaunchOnExitTask {}
|
||||
|
||||
impl Task for LaunchOnExitTask {
|
||||
|
||||
fn execute(
|
||||
&mut self,
|
||||
_: Vec<TaskParamType>,
|
||||
|
@ -25,7 +24,7 @@ impl Task for LaunchOnExitTask {
|
|||
) -> Result<TaskParamType, String> {
|
||||
let pkg = &context.database.packages.first();
|
||||
if pkg.is_none() {
|
||||
return Ok(TaskParamType::None)
|
||||
return Ok(TaskParamType::None);
|
||||
}
|
||||
let pkg = pkg.unwrap();
|
||||
|
||||
|
@ -41,12 +40,12 @@ impl Task for LaunchOnExitTask {
|
|||
.as_ref()
|
||||
.log_expect("Should have packages by now")
|
||||
.packages
|
||||
{
|
||||
if pkg.name == description.name {
|
||||
metadata = Some(description.clone());
|
||||
break;
|
||||
}
|
||||
{
|
||||
if pkg.name == description.name {
|
||||
metadata = Some(description.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let package_desc = match metadata {
|
||||
Some(v) => v,
|
||||
|
@ -58,7 +57,10 @@ impl Task for LaunchOnExitTask {
|
|||
|
||||
// copy the path to the actual exe into launcher_path so it'll load it on exit
|
||||
context.launcher_path = shortcut.map(|s| {
|
||||
path.join(s.relative_path.clone()).to_str().map(|t| { t.to_string() }).unwrap()
|
||||
path.join(s.relative_path.clone())
|
||||
.to_str()
|
||||
.map(|t| t.to_string())
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
Ok(TaskParamType::None)
|
||||
|
@ -71,4 +73,4 @@ impl Task for LaunchOnExitTask {
|
|||
fn name(&self) -> String {
|
||||
"LaunchOnExitTask".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ pub mod install_global_shortcut;
|
|||
pub mod install_pkg;
|
||||
pub mod install_shortcuts;
|
||||
pub mod launch_installed_on_exit;
|
||||
pub mod remove_target_dir;
|
||||
pub mod resolver;
|
||||
pub mod save_database;
|
||||
pub mod save_executable;
|
||||
|
@ -26,7 +27,6 @@ pub mod uninstall;
|
|||
pub mod uninstall_global_shortcut;
|
||||
pub mod uninstall_pkg;
|
||||
pub mod uninstall_shortcuts;
|
||||
pub mod remove_target_dir;
|
||||
|
||||
/// An abstraction over the various parameters that can be passed around.
|
||||
pub enum TaskParamType {
|
||||
|
|
|
@ -64,7 +64,7 @@ impl Task for UninstallPackageTask {
|
|||
));
|
||||
|
||||
let mut directories = Vec::new();
|
||||
|
||||
|
||||
let max = package.files.len();
|
||||
for (i, file) in package.files.iter().enumerate() {
|
||||
let name = file.clone();
|
||||
|
|
Loading…
Reference in a new issue