GeezerVison is showing github.com — Add additional check to feather-data build script to prevent rebuildi… · BuggStream/feather@5a856c3
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: data/build.rs +12-6Lines changed: 12 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -use reqwest; |
2 | 1 | use std::env; |
3 | 2 | use std::error::Error; |
4 | 3 | use std::fs; |
@@ -9,10 +8,14 @@ use std::process::Command; |
9 | 8 |
|
10 | 9 | fn main() -> Result<(), Box<dyn Error>> { |
11 | 10 | let path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/minecraft")); |
12 | | - dbg!(path); |
13 | 11 | let path_server = path.join("server.jar"); |
| 12 | + |
14 | 13 | println!("cargo:rerun-if-changed={}", &path.display()); |
15 | 14 |
|
| 15 | + if data_exists(path).unwrap_or(false) { |
| 16 | + return Ok(()); |
| 17 | + } |
| 18 | + |
16 | 19 | let _ = fs::remove_dir_all(&path); |
17 | 20 | fs::create_dir_all(&path)?; |
18 | 21 |
|
@@ -22,11 +25,14 @@ fn main() -> Result<(), Box<dyn Error>> { |
22 | 25 | Ok(()) |
23 | 26 | } |
24 | 27 |
|
25 | | -fn donwload<P: AsRef<Path>>(server: P) -> Result<(), Box<dyn Error>> { |
26 | | - if File::open(&server).is_ok() { |
27 | | - return Ok(()); |
28 | | - } |
| 28 | +fn data_exists(path: &Path) -> Result<bool, Box<dyn Error>> { |
| 29 | + Ok(File::open(path.join("server.jar")).is_ok() |
| 30 | + && File::open(path.join("assets")).is_ok() |
| 31 | + && File::open(path.join("data")).is_ok() |
| 32 | + && File::open(path.join("generated")).is_ok()) |
| 33 | +} |
29 | 34 |
|
| 35 | +fn donwload<P: AsRef<Path>>(server: P) -> Result<(), Box<dyn Error>> { |
30 | 36 | let mut response = reqwest::blocking::get("https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar")?; |
31 | 37 | let mut dest = File::create(server)?; |
32 | 38 | copy(&mut response, &mut dest)?; |
|