mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-12-22 19:05:27 +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
|
// bundle the icon
|
||||||
let mut f = File::create(output_dir.join("icon-data.bin")).unwrap();
|
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_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();
|
f.write_all(&icon_data.into_vec()).unwrap();
|
||||||
|
|
||||||
// Build and deploy frontend files
|
// Build and deploy frontend files
|
||||||
|
|
|
@ -130,8 +130,12 @@ pub fn validate_token(
|
||||||
let pub_key = if pub_key_base64.is_empty() {
|
let pub_key = if pub_key_base64.is_empty() {
|
||||||
vec![]
|
vec![]
|
||||||
} else {
|
} else {
|
||||||
base64::decode(&pub_key_base64)
|
base64::decode(&pub_key_base64).map_err(|e| {
|
||||||
.map_err(|e| format!("Configured public key was not empty and did not decode as base64 {:?}", 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
|
// Configure validation for audience and issuer if the configuration provides it
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn handle(service: &WebService, req: Request) -> Future {
|
||||||
let mut to_install = Vec::new();
|
let mut to_install = Vec::new();
|
||||||
let mut path: Option<String> = None;
|
let mut path: Option<String> = None;
|
||||||
let mut force_install = false;
|
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
|
// Transform results into just an array of stuff to install
|
||||||
for (key, value) in &results {
|
for (key, value) in &results {
|
||||||
|
@ -66,7 +66,13 @@ pub fn handle(service: &WebService, req: Request) -> Future {
|
||||||
framework.set_install_dir(&path);
|
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);
|
error!("Install error occurred: {:?}", v);
|
||||||
if let Err(v) = sender.send(InstallMessage::Error(v)) {
|
if let Err(v) = sender.send(InstallMessage::Error(v)) {
|
||||||
error!("Failed to send install error: {:?}", v);
|
error!("Failed to send install error: {:?}", v);
|
||||||
|
|
|
@ -18,7 +18,6 @@ use crate::logging::LoggingErrors;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
||||||
/// Struct used by serde to send a JSON payload to the client containing an optional value.
|
/// Struct used by serde to send a JSON payload to the client containing an optional value.
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct VerifyResponse {
|
struct VerifyResponse {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use wry::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{Event, StartCause, WindowEvent},
|
event::{Event, StartCause, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::{WindowBuilder, Icon},
|
window::{Icon, WindowBuilder},
|
||||||
},
|
},
|
||||||
webview::{RpcResponse, WebViewBuilder},
|
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");
|
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 event_loop = EventLoop::new();
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_title(format!("{} Installer", app_name))
|
.with_title(format!("{} Installer", app_name))
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl InstallerFramework {
|
||||||
uninstall_items,
|
uninstall_items,
|
||||||
fresh_install,
|
fresh_install,
|
||||||
create_desktop_shortcuts,
|
create_desktop_shortcuts,
|
||||||
force_install
|
force_install,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut tree = DependencyTree::build(task);
|
let mut tree = DependencyTree::build(task);
|
||||||
|
|
|
@ -201,9 +201,15 @@ mod natives {
|
||||||
.log_expect("Unable to convert log path to string")
|
.log_expect("Unable to convert log path to string")
|
||||||
.replace(" ", "\\ ");
|
.replace(" ", "\\ ");
|
||||||
|
|
||||||
let install_path = path.to_str().log_expect("Unable to convert 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 target_arguments = format!(
|
||||||
|
"/C choice /C Y /N /D Y /T 2 & del {} {} & rmdir {}",
|
||||||
|
tool, log, install_path
|
||||||
|
);
|
||||||
|
|
||||||
info!("Launching cmd with {:?}", target_arguments);
|
info!("Launching cmd with {:?}", target_arguments);
|
||||||
|
|
||||||
|
@ -333,13 +339,13 @@ mod natives {
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
mod natives {
|
mod natives {
|
||||||
use std::fs::{remove_file, remove_dir};
|
use std::fs::{remove_dir, remove_file};
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use crate::logging::LoggingErrors;
|
use crate::logging::LoggingErrors;
|
||||||
|
|
||||||
use sysinfo::{ProcessExt, SystemExt, PidExt};
|
use sysinfo::{PidExt, ProcessExt, SystemExt};
|
||||||
|
|
||||||
use dirs;
|
use dirs;
|
||||||
|
|
||||||
|
@ -423,7 +429,9 @@ mod natives {
|
||||||
/// Cleans up the installer
|
/// Cleans up the installer
|
||||||
pub fn burn_on_exit(app_name: &str) {
|
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 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))) {
|
if let Err(e) = remove_file(exe_dir.join(format!("{}_installer.log", app_name))) {
|
||||||
// No regular logging now.
|
// No regular logging now.
|
||||||
|
|
|
@ -23,9 +23,7 @@ impl Version {
|
||||||
fn coarse_into_semver(&self) -> SemverVersion {
|
fn coarse_into_semver(&self) -> SemverVersion {
|
||||||
match *self {
|
match *self {
|
||||||
Version::Semver(ref version) => version.to_owned(),
|
Version::Semver(ref version) => version.to_owned(),
|
||||||
Version::Integer(ref version) => {
|
Version::Integer(ref version) => SemverVersion::new(version.to_owned(), 0u64, 0u64),
|
||||||
SemverVersion::new(version.to_owned(), 0u64, 0u64)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@ impl Task for CheckAuthorizationTask {
|
||||||
) -> Result<TaskParamType, String> {
|
) -> Result<TaskParamType, String> {
|
||||||
assert_eq!(input.len(), 1);
|
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 {
|
let (version, file) = match params {
|
||||||
TaskParamType::File(v, f) => Ok((v, f)),
|
TaskParamType::File(v, f) => Ok((v, f)),
|
||||||
_ => Err("Unexpected TaskParamType in CheckAuthorization: {:?}"),
|
_ => Err("Unexpected TaskParamType in CheckAuthorization: {:?}"),
|
||||||
|
|
|
@ -28,7 +28,9 @@ impl Task for DownloadPackageTask {
|
||||||
) -> Result<TaskParamType, String> {
|
) -> Result<TaskParamType, String> {
|
||||||
assert_eq!(input.len(), 1);
|
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 {
|
let (version, file, auth) = match file {
|
||||||
TaskParamType::Authentication(v, f, auth) => (v, f, auth),
|
TaskParamType::Authentication(v, f, auth) => (v, f, auth),
|
||||||
_ => return Err("Unexpected param type to download package".to_string()),
|
_ => 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_dir::VerifyInstallDirTask;
|
||||||
use crate::tasks::install_global_shortcut::InstallGlobalShortcutsTask;
|
use crate::tasks::install_global_shortcut::InstallGlobalShortcutsTask;
|
||||||
use crate::tasks::install_pkg::InstallPackageTask;
|
use crate::tasks::install_pkg::InstallPackageTask;
|
||||||
|
use crate::tasks::launch_installed_on_exit::LaunchOnExitTask;
|
||||||
use crate::tasks::remove_target_dir::RemoveTargetDirTask;
|
use crate::tasks::remove_target_dir::RemoveTargetDirTask;
|
||||||
use crate::tasks::save_executable::SaveExecutableTask;
|
use crate::tasks::save_executable::SaveExecutableTask;
|
||||||
use crate::tasks::uninstall_pkg::UninstallPackageTask;
|
use crate::tasks::uninstall_pkg::UninstallPackageTask;
|
||||||
use crate::tasks::launch_installed_on_exit::LaunchOnExitTask;
|
|
||||||
|
|
||||||
use crate::tasks::Task;
|
use crate::tasks::Task;
|
||||||
use crate::tasks::TaskDependency;
|
use crate::tasks::TaskDependency;
|
||||||
|
@ -72,7 +72,10 @@ impl Task for InstallTask {
|
||||||
for item in &self.items {
|
for item in &self.items {
|
||||||
elements.push(TaskDependency::build(
|
elements.push(TaskDependency::build(
|
||||||
TaskOrdering::Pre,
|
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(
|
elements.push(TaskDependency::build(
|
||||||
TaskOrdering::Post,
|
TaskOrdering::Post,
|
||||||
Box::new(LaunchOnExitTask {})
|
Box::new(LaunchOnExitTask {}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,10 @@ impl Task for InstallDesktopShortcutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
messenger(&TaskMessage::DisplayMessage(
|
messenger(&TaskMessage::DisplayMessage(
|
||||||
&format!("Generating desktop shortcuts for package {:?}...", self.name),
|
&format!(
|
||||||
|
"Generating desktop shortcuts for package {:?}...",
|
||||||
|
self.name
|
||||||
|
),
|
||||||
0.0,
|
0.0,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -108,6 +111,9 @@ impl Task for InstallDesktopShortcutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name(&self) -> String {
|
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 {}
|
pub struct LaunchOnExitTask {}
|
||||||
|
|
||||||
impl Task for LaunchOnExitTask {
|
impl Task for LaunchOnExitTask {
|
||||||
|
|
||||||
fn execute(
|
fn execute(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Vec<TaskParamType>,
|
_: Vec<TaskParamType>,
|
||||||
|
@ -25,7 +24,7 @@ impl Task for LaunchOnExitTask {
|
||||||
) -> Result<TaskParamType, String> {
|
) -> Result<TaskParamType, String> {
|
||||||
let pkg = &context.database.packages.first();
|
let pkg = &context.database.packages.first();
|
||||||
if pkg.is_none() {
|
if pkg.is_none() {
|
||||||
return Ok(TaskParamType::None)
|
return Ok(TaskParamType::None);
|
||||||
}
|
}
|
||||||
let pkg = pkg.unwrap();
|
let pkg = pkg.unwrap();
|
||||||
|
|
||||||
|
@ -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
|
// copy the path to the actual exe into launcher_path so it'll load it on exit
|
||||||
context.launcher_path = shortcut.map(|s| {
|
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)
|
Ok(TaskParamType::None)
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub mod install_global_shortcut;
|
||||||
pub mod install_pkg;
|
pub mod install_pkg;
|
||||||
pub mod install_shortcuts;
|
pub mod install_shortcuts;
|
||||||
pub mod launch_installed_on_exit;
|
pub mod launch_installed_on_exit;
|
||||||
|
pub mod remove_target_dir;
|
||||||
pub mod resolver;
|
pub mod resolver;
|
||||||
pub mod save_database;
|
pub mod save_database;
|
||||||
pub mod save_executable;
|
pub mod save_executable;
|
||||||
|
@ -26,7 +27,6 @@ pub mod uninstall;
|
||||||
pub mod uninstall_global_shortcut;
|
pub mod uninstall_global_shortcut;
|
||||||
pub mod uninstall_pkg;
|
pub mod uninstall_pkg;
|
||||||
pub mod uninstall_shortcuts;
|
pub mod uninstall_shortcuts;
|
||||||
pub mod remove_target_dir;
|
|
||||||
|
|
||||||
/// An abstraction over the various parameters that can be passed around.
|
/// An abstraction over the various parameters that can be passed around.
|
||||||
pub enum TaskParamType {
|
pub enum TaskParamType {
|
||||||
|
|
Loading…
Reference in a new issue