From 42c0bcc7bc6e94af1e86dce1b7afc4a39c7b848a Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sun, 19 Jul 2020 08:29:54 -0500 Subject: [PATCH] Fixed regex error and added ensured all area is backed up + the regex to match region files was only matching one number + ensured the save radius includes all blocks requested --- src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index c53b1b9..0076537 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ struct Region { impl Region { fn from_string(string: String) -> Option { - let re = Regex::new(r"r\.(?P-?[0-9])+\.(?P-?[0-9])").unwrap(); + let re = Regex::new(r"r\.(?P-?[0-9]*)+\.(?P-?[0-9]*)").unwrap(); if re.is_match(string.as_str()) { let captures = re.captures(string.as_str()).unwrap(); @@ -90,11 +90,7 @@ fn backup_region( backup_dir.push(dir_name); create_dir(&backup_dir)?; - let save_radius = if save_radius < 512 { - 1 as i64 - } else { - (save_radius / 512) as i64 - }; + let save_radius = (save_radius as f64 / 512.0).ceil() as i64; for entry in src_dir.read_dir()? { let entry = entry?;