Lots of fixes #4

Merged
MojaveMF merged 2 commits from main into main 2023-11-04 06:50:05 -05:00
4 changed files with 26 additions and 10 deletions

View File

@ -1,9 +1,23 @@
use std::fs;
use std::env; use std::env;
use std::fs;
use winres::WindowsResource; 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() { fn main() {
// Get the current build date and time // 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 // Write the build date to a file
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
@ -27,4 +41,4 @@ fn main() {
} }
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
} }

View File

@ -6,8 +6,8 @@ pub const FILES_TO_DOWNLOAD: [[&str; 2]; 17] = [
["redist.zip", "./"], ["redist.zip", "./"],
["content-textures.zip", "./content/textures"], ["content-textures.zip", "./content/textures"],
["content-textures2.zip", "./content/textures"], ["content-textures2.zip", "./content/textures"],
["content-textures3.zip", "./content/textures"], ["content-textures3.zip", "./PlatformContent/pc/textures"],
["content-terrain.zip", "./content/terrain"], ["content-terrain.zip", "./PlatformContent/pc/terrain"],
["content-fonts.zip", "./content/fonts"], ["content-fonts.zip", "./content/fonts"],
["content-sounds.zip", "./content/sounds"], ["content-sounds.zip", "./content/sounds"],
["content-scripts.zip", "./content/scripts"], ["content-scripts.zip", "./content/scripts"],

View File

@ -5,6 +5,7 @@ use md5;
use metadata::LevelFilter; use metadata::LevelFilter;
use reqwest::Client; use reqwest::Client;
use std::path::PathBuf; use std::path::PathBuf;
use tokio::fs::create_dir_all;
use tokio::task::JoinSet; use tokio::task::JoinSet;
use zip_extract; use zip_extract;
@ -230,9 +231,9 @@ async fn main() {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
debug!("Bootstrapper errored with error {}", 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(); std::fs::remove_file(latest_bootstrapper_path.clone()).unwrap();
download_file( download_to_file(
&http_client, &http_client,
&format!( &format!(
"https://{}/{}-{}", "https://{}/{}-{}",
@ -289,7 +290,10 @@ async fn main() {
let mut set = JoinSet::new(); 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( set.spawn(download_and_extract(
value.to_string(), value.to_string(),
version_url_prefix.clone(), version_url_prefix.clone(),

View File

@ -4,7 +4,6 @@
use colored::*; use colored::*;
use dirs::data_local_dir; use dirs::data_local_dir;
use futures_util::StreamExt; use futures_util::StreamExt;
use md5;
use reqwest::Client; use reqwest::Client;
use reqwest::ClientBuilder; use reqwest::ClientBuilder;
use std::io::Cursor; use std::io::Cursor;
@ -16,7 +15,6 @@ use zip_extract;
use crate::constants::*; use crate::constants::*;
use tracing::*; use tracing::*;
#[cfg(not(target_os = "windows"))]
use std::io::prelude::*; use std::io::prelude::*;
/* /*
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]