From 99b4b75e24767cf08879fb2da9999489c43dca19 Mon Sep 17 00:00:00 2001 From: mojavemf Date: Sat, 4 Nov 2023 11:37:58 +0000 Subject: [PATCH 1/2] Lots of fixes --- build.rs | 20 +++++++++++++++++--- src/main.rs | 4 ++-- src/util/mod.rs | 2 -- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 24664fb..d115e97 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,23 @@ -use std::fs; use std::env; +use std::fs; use winres::WindowsResource; + +#[cfg(debug_assertions)] +fn main() { + let build_date = chrono::Utc::now() + .format("%Y-%m-%d %H:%M:%S UTC") + .to_string(); + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = format!("{}/build_date.txt", out_dir); + fs::write(&dest_path, &build_date).unwrap(); +} + +#[cfg(not(debug_assertions))] fn main() { // Get the current build date and time - let build_date = chrono::Utc::now().format("%Y-%m-%d %H:%M:%S UTC").to_string(); + let build_date = chrono::Utc::now() + .format("%Y-%m-%d %H:%M:%S UTC") + .to_string(); // Write the build date to a file let out_dir = env::var("OUT_DIR").unwrap(); @@ -27,4 +41,4 @@ fn main() { } println!("cargo:rerun-if-changed=build.rs"); -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 97c53d3..3f52b6c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,9 +230,9 @@ async fn main() { Ok(_) => {} Err(e) => { debug!("Bootstrapper errored with error {}", e); - info("Found bootstrapper was corrupted! Downloading..."); + info!("Found bootstrapper was corrupted! Downloading..."); std::fs::remove_file(latest_bootstrapper_path.clone()).unwrap(); - download_file( + download_to_file( &http_client, &format!( "https://{}/{}-{}", diff --git a/src/util/mod.rs b/src/util/mod.rs index 5927a4c..d797ff9 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -4,7 +4,6 @@ use colored::*; use dirs::data_local_dir; use futures_util::StreamExt; -use md5; use reqwest::Client; use reqwest::ClientBuilder; use std::io::Cursor; @@ -16,7 +15,6 @@ use zip_extract; use crate::constants::*; use tracing::*; -#[cfg(not(target_os = "windows"))] use std::io::prelude::*; /* #[cfg(not(target_os = "windows"))] -- 2.40.1 From 1e5f3532856e4028567f91bec172e4defe47e6ca Mon Sep 17 00:00:00 2001 From: mojavemf Date: Sat, 4 Nov 2023 11:48:47 +0000 Subject: [PATCH 2/2] Fixed platform content folder --- src/constants/mod.rs | 4 ++-- src/main.rs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/constants/mod.rs b/src/constants/mod.rs index d5e1e23..1308411 100644 --- a/src/constants/mod.rs +++ b/src/constants/mod.rs @@ -6,8 +6,8 @@ pub const FILES_TO_DOWNLOAD: [[&str; 2]; 17] = [ ["redist.zip", "./"], ["content-textures.zip", "./content/textures"], ["content-textures2.zip", "./content/textures"], - ["content-textures3.zip", "./content/textures"], - ["content-terrain.zip", "./content/terrain"], + ["content-textures3.zip", "./PlatformContent/pc/textures"], + ["content-terrain.zip", "./PlatformContent/pc/terrain"], ["content-fonts.zip", "./content/fonts"], ["content-sounds.zip", "./content/sounds"], ["content-scripts.zip", "./content/scripts"], diff --git a/src/main.rs b/src/main.rs index 3f52b6c..ec4e162 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use md5; use metadata::LevelFilter; use reqwest::Client; use std::path::PathBuf; +use tokio::fs::create_dir_all; use tokio::task::JoinSet; use zip_extract; @@ -289,7 +290,10 @@ async fn main() { let mut set = JoinSet::new(); - for [value, _] in FILES_TO_DOWNLOAD { + for [value, path] in FILES_TO_DOWNLOAD { + create_dir_all(current_version_directory.join(path)) + .await + .unwrap(); set.spawn(download_and_extract( value.to_string(), version_url_prefix.clone(), -- 2.40.1