mirror of
https://github.com/yuhkix/wuwa-downloader.git
synced 2025-06-06 17:53:44 +00:00
small fix that should make compiling for linux users work
This commit is contained in:
parent
ef9cbad14a
commit
4d70933c4f
6 changed files with 59 additions and 16 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -150,9 +150,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctrlc"
|
name = "ctrlc"
|
||||||
version = "3.4.5"
|
version = "3.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3"
|
checksum = "697b5419f348fd5ae2478e8018cb016c00a5881c7f46c717de98ffd135a5651c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -4,20 +4,22 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
winres = "0.1.12"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
colored = "3.0.0"
|
colored = "3.0.0"
|
||||||
md-5 = "0.10.6"
|
md-5 = "0.10.6"
|
||||||
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
|
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
serde = "1.0.219"
|
serde = "1.0.219"
|
||||||
winconsole = "0.11.1"
|
ctrlc = "3.4.6"
|
||||||
ctrlc = "3.4.5"
|
|
||||||
shellexpand = "3.1.0"
|
shellexpand = "3.1.0"
|
||||||
flate2 = "1.1.1"
|
flate2 = "1.1.1"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
winconsole = "0.11.1"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
|
winres = "0.1.12"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
lto = true
|
lto = true
|
||||||
|
|
3
build.rs
3
build.rs
|
@ -1,5 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
let mut res = winres::WindowsResource::new();
|
let mut res = winres::WindowsResource::new();
|
||||||
res.set_icon("zani.ico");
|
res.set_icon("zani.ico");
|
||||||
res.compile().unwrap();
|
res.compile().unwrap();
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::{fs::File, io, sync::Arc, thread, time::{Duration, Instant}};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
#[cfg(windows)]
|
||||||
use winconsole::console::{clear, set_title};
|
use winconsole::console::{clear, set_title};
|
||||||
|
|
||||||
use crate::{config::{cfg::Config, status::Status}, download::progress::DownloadProgress, io::logging::log_error, network::client::download_file};
|
use crate::{config::{cfg::Config, status::Status}, download::progress::DownloadProgress, io::logging::log_error, network::client::download_file};
|
||||||
|
@ -95,7 +96,10 @@ pub fn get_version(data: &Value, category: &str, version: &str) -> Result<String
|
||||||
|
|
||||||
pub fn exit_with_error(log_file: &File, error: &str) -> ! {
|
pub fn exit_with_error(log_file: &File, error: &str) -> ! {
|
||||||
log_error(log_file, error);
|
log_error(log_file, error);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} {}", Status::error(), error);
|
println!("{} {}", Status::error(), error);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -162,7 +166,9 @@ pub fn start_title_thread(
|
||||||
eta_str
|
eta_str
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
set_title(&title).unwrap();
|
set_title(&title).unwrap();
|
||||||
|
|
||||||
thread::sleep(Duration::from_secs(1));
|
thread::sleep(Duration::from_secs(1));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -171,7 +177,10 @@ pub fn start_title_thread(
|
||||||
pub fn setup_ctrlc(should_stop: Arc<std::sync::atomic::AtomicBool>) {
|
pub fn setup_ctrlc(should_stop: Arc<std::sync::atomic::AtomicBool>) {
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
should_stop.store(true, std::sync::atomic::Ordering::SeqCst);
|
should_stop.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
|
|
||||||
println!("\n{} Download interrupted by user", Status::warning());
|
println!("\n{} Download interrupted by user", Status::warning());
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
#[cfg(windows)]
|
||||||
use winconsole::console::{clear, set_title};
|
use winconsole::console::{clear, set_title};
|
||||||
|
|
||||||
use wuwa_downloader::{
|
use wuwa_downloader::{
|
||||||
|
@ -17,7 +18,9 @@ use wuwa_downloader::{
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(windows)]
|
||||||
set_title("Wuthering Waves Downloader").unwrap();
|
set_title("Wuthering Waves Downloader").unwrap();
|
||||||
|
|
||||||
let log_file = setup_logging();
|
let log_file = setup_logging();
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
|
|
||||||
|
@ -27,6 +30,8 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let folder = get_dir();
|
let folder = get_dir();
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
println!(
|
println!(
|
||||||
"\n{} Download folder: {}\n",
|
"\n{} Download folder: {}\n",
|
||||||
|
@ -47,6 +52,8 @@ fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let total_size = calculate_total_size(resources, &client, &config);
|
let total_size = calculate_total_size(resources, &client, &config);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
|
|
||||||
let (should_stop, success, progress) = track_progress(total_size);
|
let (should_stop, success, progress) = track_progress(total_size);
|
||||||
|
@ -74,7 +81,9 @@ fn main() {
|
||||||
should_stop.store(true, std::sync::atomic::Ordering::SeqCst);
|
should_stop.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||||
title_thread.join().unwrap();
|
title_thread.join().unwrap();
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
|
|
||||||
print_results(
|
print_results(
|
||||||
success.load(std::sync::atomic::Ordering::SeqCst),
|
success.load(std::sync::atomic::Ordering::SeqCst),
|
||||||
resources.len(),
|
resources.len(),
|
||||||
|
|
|
@ -2,8 +2,9 @@ use colored::Colorize;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde_json::{from_reader, from_str, Value};
|
use serde_json::{from_reader, from_str, Value};
|
||||||
use winconsole::console::{self, clear};
|
|
||||||
use std::{io::{Read, Write}, fs, io, path::Path, time::Duration};
|
use std::{io::{Read, Write}, fs, io, path::Path, time::Duration};
|
||||||
|
#[cfg(windows)]
|
||||||
|
use winconsole::console::clear;
|
||||||
|
|
||||||
use crate::config::cfg::Config;
|
use crate::config::cfg::Config;
|
||||||
use crate::download::progress::DownloadProgress;
|
use crate::download::progress::DownloadProgress;
|
||||||
|
@ -27,7 +28,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
Ok(resp) => resp,
|
Ok(resp) => resp,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log_error(log_file, &format!("Error fetching index file: {}", e));
|
log_error(log_file, &format!("Error fetching index file: {}", e));
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Error fetching index file: {}", Status::error(), e);
|
println!("{} Error fetching index file: {}", Status::error(), e);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -38,7 +42,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
let msg = format!("Error fetching index file: HTTP {}", response.status());
|
let msg = format!("Error fetching index file: HTTP {}", response.status());
|
||||||
log_error(log_file, &msg);
|
log_error(log_file, &msg);
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} {}", Status::error(), msg);
|
println!("{} {}", Status::error(), msg);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -55,7 +62,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
if let Err(e) = response.copy_to(&mut buffer) {
|
if let Err(e) = response.copy_to(&mut buffer) {
|
||||||
log_error(log_file, &format!("Error reading index file bytes: {}", e));
|
log_error(log_file, &format!("Error reading index file bytes: {}", e));
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Error reading index file: {}", Status::error(), e);
|
println!("{} Error reading index file: {}", Status::error(), e);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -66,7 +76,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
let mut decompressed_text = String::new();
|
let mut decompressed_text = String::new();
|
||||||
if let Err(e) = gz.read_to_string(&mut decompressed_text) {
|
if let Err(e) = gz.read_to_string(&mut decompressed_text) {
|
||||||
log_error(log_file, &format!("Error decompressing index file: {}", e));
|
log_error(log_file, &format!("Error decompressing index file: {}", e));
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Error decompressing index file: {}", Status::error(), e);
|
println!("{} Error decompressing index file: {}", Status::error(), e);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -81,7 +94,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
log_file,
|
log_file,
|
||||||
&format!("Error reading index file response: {}", e),
|
&format!("Error reading index file response: {}", e),
|
||||||
);
|
);
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Error reading index file: {}", Status::error(), e);
|
println!("{} Error reading index file: {}", Status::error(), e);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -96,7 +112,10 @@ pub fn fetch_index(client: &Client, config: &Config, log_file: &fs::File) -> Val
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log_error(log_file, &format!("Error parsing index file JSON: {}", e));
|
log_error(log_file, &format!("Error parsing index file JSON: {}", e));
|
||||||
console::clear().unwrap();
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Error parsing index file: {}", Status::error(), e);
|
println!("{} Error parsing index file: {}", Status::error(), e);
|
||||||
println!("\n{} Press Enter to exit...", Status::warning());
|
println!("\n{} Press Enter to exit...", Status::warning());
|
||||||
let _ = io::stdin().read_line(&mut String::new());
|
let _ = io::stdin().read_line(&mut String::new());
|
||||||
|
@ -293,7 +312,10 @@ fn download_single_file(
|
||||||
|
|
||||||
pub fn get_config(client: &Client) -> Result<Config, String> {
|
pub fn get_config(client: &Client) -> Result<Config, String> {
|
||||||
let selected_index_url = fetch_gist(client)?;
|
let selected_index_url = fetch_gist(client)?;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
clear().unwrap();
|
clear().unwrap();
|
||||||
|
|
||||||
println!("{} Fetching download configuration...", Status::info());
|
println!("{} Fetching download configuration...", Status::info());
|
||||||
|
|
||||||
let mut response = client
|
let mut response = client
|
||||||
|
|
Loading…
Reference in a new issue