mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2025-11-05 02:15:04 +00:00
* platform: fix build on Linux and update web-view * deps: replace xz-decom with xz2 and update deps * platform: fix regression... ... that prevents the build on Windows * linux: implement platform-dependent functions * travis: add macos and windows CI * travis: use official Rust Docker image * Update Cargo.lock for new version * Break apart REST into separate services This cleans up locking, ensures consistent futures for all endpoints and enhances code re-use. * Clean up codebase, fixing minor errors * Update packages, use async client for downloading config While this has a hell of a lot more boilerplate, this is quite a bit cleaner. * Add explicit 'dyn's as per Rust nightly requirements * Migrate self updating functions to own module * Migrate assets to server module * Use patched web-view to fix dialogs, remove nfd * Implement basic dark mode * Revert window.close usage * ui: split files and use Webpack * frontend: ui: include prebuilt assets... ... and update rust side stuff * build: integrate webpack building into build.rs * Polish Vue UI split * Add instructions for node + yarn * native: fix uninstall self-destruction behavior...... by not showing the command prompt window and fork-spawning the cmd * native: deal with Unicode issues in native APIs * native: further improve Unicode support on Windows * travis: add cache and fix issues * ui: use Buefy components to... ... beautify the UI * ui: makes error message selectable * Make launcher mode behaviour more robust * Fix error display on launcher pages * Correctly handle exit on error * Bump installer version
71 lines
2.1 KiB
Rust
71 lines
2.1 KiB
Rust
//! frontend/rest/services/install.rs
|
|
//!
|
|
//! The /api/install call installs a set of packages dictated by a POST request.
|
|
|
|
use frontend::rest::services::stream_progress;
|
|
use frontend::rest::services::Future;
|
|
use frontend::rest::services::Request;
|
|
use frontend::rest::services::WebService;
|
|
|
|
use logging::LoggingErrors;
|
|
|
|
use installer::InstallMessage;
|
|
|
|
use futures::future::Future as _;
|
|
use futures::stream::Stream;
|
|
|
|
use url::form_urlencoded;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
pub fn handle(service: &WebService, req: Request) -> Future {
|
|
let framework = service.framework.clone();
|
|
|
|
Box::new(req.body().concat2().map(move |b| {
|
|
let results = form_urlencoded::parse(b.as_ref())
|
|
.into_owned()
|
|
.collect::<HashMap<String, String>>();
|
|
|
|
let mut to_install = Vec::new();
|
|
let mut path: Option<String> = None;
|
|
|
|
// Transform results into just an array of stuff to install
|
|
for (key, value) in &results {
|
|
if key == "path" {
|
|
path = Some(value.to_owned());
|
|
continue;
|
|
}
|
|
|
|
if value == "true" {
|
|
to_install.push(key.to_owned());
|
|
}
|
|
}
|
|
|
|
// The frontend always provides this
|
|
let path =
|
|
path.log_expect("No path specified by frontend when one should have already existed");
|
|
|
|
stream_progress(move |sender| {
|
|
let mut framework = framework
|
|
.write()
|
|
.log_expect("InstallerFramework has been dirtied");
|
|
|
|
let new_install = !framework.preexisting_install;
|
|
if new_install {
|
|
framework.set_install_dir(&path);
|
|
}
|
|
|
|
if let Err(v) = framework.install(to_install, &sender, new_install) {
|
|
error!("Install error occurred: {:?}", v);
|
|
if let Err(v) = sender.send(InstallMessage::Error(v)) {
|
|
error!("Failed to send install error: {:?}", v);
|
|
}
|
|
}
|
|
|
|
if let Err(v) = sender.send(InstallMessage::EOF) {
|
|
error!("Failed to send EOF to client: {:?}", v);
|
|
}
|
|
})
|
|
}))
|
|
}
|