From c1364091165f090e7f0e45db5f6a94d38f22eacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 14 Jul 2022 18:04:34 +0200 Subject: [PATCH] Skip nonexistent paths and disable text replacement --- src/main.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4ffd7b5..18b668e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,25 +66,25 @@ fn main() { assert_eq!(unity, &version.trim()); // 1. texts - let status = Command::new("python") - .env("PYTHONIOENCODING", "utf-8") - .arg("scripts/UnityTextModifier.py") - .arg(&assets) - .arg("assets/text-edits.json") - .arg(&directory_assets) - .status() - .expect("failed to execute UnityTextModifier.py"); + if arc_number.clone() < 9 { + let status = Command::new("python") + .env("PYTHONIOENCODING", "utf-8") + .arg("scripts/UnityTextModifier.py") + .arg(&assets) + .arg("assets/text-edits.json") + .arg(&directory_assets) + .status() + .expect("failed to execute UnityTextModifier.py"); - assert!(status.success()); + assert!(status.success()); + } // 2. images copy_images("assets/images/shared", &directory_assets); copy_images(format!("assets/images/{}", &arc_type).as_ref(), &directory_assets); copy_images(format!("assets/images/specific/{}", &chapter).as_ref(), &directory_assets); let version_specific_path = format!("assets/images/version-specific/{}-{}", &chapter, &unity); - if Path::new(&version_specific_path).exists() { - copy_images(version_specific_path.as_ref(), &directory_assets); - } + copy_images(version_specific_path.as_ref(), &directory_assets); if arc_number.clone() == 9 { fs::rename("output/assets/configbg_Texture2D.png", "output/assets/56configbg_Texture2D.png").expect("Unable to rename"); } else if arc_number.clone() == 8 { @@ -202,6 +202,10 @@ fn main() { } fn copy_images(from: &str, to: &str) { + if ! Path::new(&from).exists() { + println!("Path {} not found", from); + return + } println!("Copying files from {}", from); for entry in fs::read_dir(from).expect("Can't read directory") { let path = entry.unwrap().path(); @@ -210,6 +214,10 @@ fn copy_images(from: &str, to: &str) { } fn copy_files(from: &str, to: &str) { + if ! Path::new(&from).exists() { + println!("Path {} not found", from); + return + } println!("Copying files from {}", from); for entry in fs::read_dir(from).expect("Can't read directory") { let path = entry.unwrap().path();