You've already forked AstralRinth
forked from didirus/AstralRinth
Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter (#288)
* Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter * Add pack file path validation * Fix compilation error caused by incorrect merge
This commit is contained in:
57
build.rs
57
build.rs
@@ -1,58 +1,3 @@
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
fn main() {
|
||||
let dir = std::env::var("OUT_DIR").unwrap();
|
||||
let mut target = PathBuf::from(dir);
|
||||
target.pop();
|
||||
target.pop();
|
||||
target.pop();
|
||||
target.push("migrations");
|
||||
println!("Output: {}", target.to_str().unwrap());
|
||||
copy("migrations", target).unwrap();
|
||||
}
|
||||
|
||||
pub fn copy<U: AsRef<Path>, V: AsRef<Path>>(from: U, to: V) -> Result<(), std::io::Error> {
|
||||
let mut stack = vec![PathBuf::from(from.as_ref())];
|
||||
|
||||
let output_root = PathBuf::from(to.as_ref());
|
||||
let input_root = PathBuf::from(from.as_ref()).components().count();
|
||||
|
||||
while let Some(working_path) = stack.pop() {
|
||||
println!("process: {:?}", &working_path);
|
||||
|
||||
// Generate a relative path
|
||||
let src: PathBuf = working_path.components().skip(input_root).collect();
|
||||
|
||||
// Create a destination if missing
|
||||
let dest = if src.components().count() == 0 {
|
||||
output_root.clone()
|
||||
} else {
|
||||
output_root.join(&src)
|
||||
};
|
||||
if fs::metadata(&dest).is_err() {
|
||||
println!(" mkdir: {:?}", dest);
|
||||
fs::create_dir_all(&dest)?;
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(working_path)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
stack.push(path);
|
||||
} else {
|
||||
match path.file_name() {
|
||||
Some(filename) => {
|
||||
let dest_path = dest.join(filename);
|
||||
println!(" copy: {:?} -> {:?}", &path, &dest_path);
|
||||
fs::copy(&path, &dest_path)?;
|
||||
}
|
||||
None => {
|
||||
println!("failed: {:?}", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user