mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 11:15:42 +01:00
Fix burning of files + dependencies on Linux
This commit is contained in:
parent
cc0284ed74
commit
5e48f191b4
865
Cargo.lock
generated
865
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ futures = "*"
|
|||||||
mime_guess = "1.8.3"
|
mime_guess = "1.8.3"
|
||||||
url = "*"
|
url = "*"
|
||||||
|
|
||||||
reqwest = "0.8.6"
|
reqwest = {git = "https://github.com/seanmonstar/reqwest.git", rev = "68d012e"}
|
||||||
number_prefix = "0.2.7"
|
number_prefix = "0.2.7"
|
||||||
|
|
||||||
serde = "1.0.27"
|
serde = "1.0.27"
|
||||||
|
39
src/http.rs
39
src/http.rs
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! A simple wrapper around Hyper's HTTP client.
|
//! A simple wrapper around Hyper's HTTP client.
|
||||||
|
|
||||||
use hyper::header::ContentLength;
|
use reqwest::header::CONTENT_LENGTH;
|
||||||
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -19,10 +19,10 @@ pub fn build_client() -> Result<Client, String> {
|
|||||||
|
|
||||||
/// 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> {
|
||||||
let mut client = match build_client()?.get(url).send() {
|
let mut client = build_client()?
|
||||||
Ok(v) => v,
|
.get(url)
|
||||||
Err(v) => return Err(format!("Failed to GET resource: {:?}", v)),
|
.send()
|
||||||
};
|
.map_err(|x| format!("Failed to GET resource: {:?}", v))?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.text()
|
.text()
|
||||||
@ -34,26 +34,25 @@ pub fn stream_file<F>(url: &str, mut callback: F) -> Result<(), String>
|
|||||||
where
|
where
|
||||||
F: FnMut(Vec<u8>, u64) -> (),
|
F: FnMut(Vec<u8>, u64) -> (),
|
||||||
{
|
{
|
||||||
let mut client = match build_client()?.get(url).send() {
|
let mut client = build_client()?
|
||||||
Ok(v) => v,
|
.get(url)
|
||||||
Err(v) => return Err(format!("Failed to GET resource: {:?}", v)),
|
.send()
|
||||||
};
|
.map_err(|x| format!("Failed to GET resource: {:?}", v))?;
|
||||||
|
|
||||||
let size = {
|
let size = match client.headers().get(CONTENT_LENGTH) {
|
||||||
let size: Option<&ContentLength> = client.headers().get();
|
Some(ref v) => v
|
||||||
match size {
|
.to_str()
|
||||||
Some(&ContentLength(v)) => v,
|
.map_err(|x| format!("Content length header was invalid: {:?}", x))?
|
||||||
None => 0,
|
.parse()
|
||||||
}
|
.map_err(|x| format!("Failed to parse content length: {:?}", x))?,
|
||||||
|
None => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut buf = [0 as u8; 8192];
|
let mut buf = [0 as u8; 8192];
|
||||||
loop {
|
loop {
|
||||||
let len = client.read(&mut buf);
|
let len = client
|
||||||
let len = match len {
|
.read(&mut buf)
|
||||||
Ok(v) => v,
|
.map_err(|x| format!("Failed to read resource: {:?}", x))?;
|
||||||
Err(v) => return Err(format!("Failed to read resource: {:?}", v)),
|
|
||||||
};
|
|
||||||
|
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
break;
|
break;
|
||||||
|
@ -116,7 +116,13 @@ impl InstallerFramework {
|
|||||||
Err(_) => home_dir()?,
|
Err(_) => home_dir()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let file = base_dir.join(app_name);
|
let file_name = if cfg!(unix) {
|
||||||
|
format!(".{}", app_name.to_ascii_lowercase())
|
||||||
|
} else {
|
||||||
|
app_name.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let file = base_dir.join(file_name);
|
||||||
|
|
||||||
Some(file.to_str()?.to_owned())
|
Some(file.to_str()?.to_owned())
|
||||||
}
|
}
|
||||||
|
@ -117,17 +117,16 @@ mod natives {
|
|||||||
/// Cleans up the installer
|
/// Cleans up the installer
|
||||||
pub fn burn_on_exit() {
|
pub fn burn_on_exit() {
|
||||||
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
|
|
||||||
.parent()
|
|
||||||
.log_expect("Parent directory of executable could not be found");
|
|
||||||
|
|
||||||
// Thank god for *nix platforms
|
// Thank god for *nix platforms
|
||||||
if let Err(e) = remove_file(path.join("/maintenancetool")) {
|
if let Err(e) = remove_file(¤t_exe) {
|
||||||
// No regular logging now.
|
// No regular logging now.
|
||||||
eprintln!("Failed to delete maintenancetool: {:?}", e);
|
eprintln!("Failed to delete maintenancetool: {:?}", e);
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = remove_file(path.join("/installer.log")) {
|
let current_dir = env::current_dir().log_expect("Current directory cannot be found");
|
||||||
|
|
||||||
|
if let Err(e) = remove_file(current_dir.join("installer.log")) {
|
||||||
// No regular logging now.
|
// No regular logging now.
|
||||||
eprintln!("Failed to delete installer log: {:?}", e);
|
eprintln!("Failed to delete installer log: {:?}", e);
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! Contains the Github API implementation of a release source.
|
//! Contains the Github API implementation of a release source.
|
||||||
|
|
||||||
use reqwest::header::UserAgent;
|
use reqwest::header::USER_AGENT;
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@ -41,11 +41,11 @@ impl ReleaseSource for GithubReleases {
|
|||||||
.get(&format!(
|
.get(&format!(
|
||||||
"https://api.github.com/repos/{}/releases",
|
"https://api.github.com/repos/{}/releases",
|
||||||
config.repo
|
config.repo
|
||||||
)).header(UserAgent::new("liftinstall (j-selby)"))
|
)).header(USER_AGENT, "liftinstall (j-selby)")
|
||||||
.send()
|
.send()
|
||||||
.map_err(|x| format!("Error while sending HTTP request: {:?}", x))?;
|
.map_err(|x| format!("Error while sending HTTP request: {:?}", x))?;
|
||||||
|
|
||||||
if response.status() != StatusCode::Ok {
|
if response.status() != StatusCode::OK {
|
||||||
return Err(format!("Bad status code: {:?}", response.status()));
|
return Err(format!("Bad status code: {:?}", response.status()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user