feat(env): added DISABLE_GIT_LFS_CHECK

This commit is contained in:
Songtronix 2019-10-05 10:33:18 +02:00
parent 4498cece46
commit aa556ba4b3

View File

@ -30,32 +30,34 @@ fn main() {
Err(e) => panic!("failed to retrieve current git commit hash: {}", e), Err(e) => panic!("failed to retrieve current git commit hash: {}", e),
} }
// Check if git-lfs is working // Check if git-lfs is working
let asset_path: PathBuf = ["..", "assets", "voxygen", "background", "bg_main.png"] if std::env::var("DISABLE_GIT_LFS_CHECK").is_err() {
.iter() let asset_path: PathBuf = ["..", "assets", "voxygen", "background", "bg_main.png"]
.collect(); .iter()
let asset_file = match File::open(&asset_path) { .collect();
Ok(file) => file, let asset_file = match File::open(&asset_path) {
Err(e) => panic!( Ok(file) => file,
"failed to open asset file {}: {}", Err(e) => panic!(
asset_path.to_str().unwrap(), "failed to open asset file {}: {}",
e asset_path.to_str().unwrap(),
), e
}; ),
const LFS_MARKER: &[u8] = b"version https://git-lfs.github.com/spec/"; };
let mut buffer = Vec::new(); const LFS_MARKER: &[u8] = b"version https://git-lfs.github.com/spec/";
let bytes_read = asset_file let mut buffer = Vec::new();
.take(LFS_MARKER.len() as u64) let bytes_read = asset_file
.read_to_end(&mut buffer) .take(LFS_MARKER.len() as u64)
.expect("failed to read asset file"); .read_to_end(&mut buffer)
.expect("failed to read asset file");
if bytes_read == LFS_MARKER.len() && buffer == LFS_MARKER { if bytes_read == LFS_MARKER.len() && buffer == LFS_MARKER {
panic!( panic!(
"\n\nGit Large File Storage (git-lfs) has not been set up correctly.\n\ "\n\nGit Large File Storage (git-lfs) has not been set up correctly.\n\
Most common reasons:\n\ Most common reasons:\n\
\t- git-lfs was not installed before cloning this repository\n\ \t- git-lfs was not installed before cloning this repository\n\
\t- this repository was not cloned from the primary gitlab mirror.\n\ \t- this repository was not cloned from the primary gitlab mirror.\n\
\t The github mirror does not support lfs.\n\ \t The github mirror does not support lfs.\n\
See the book at https://book.veloren.net/ for details.\n\n" See the book at https://book.veloren.net/ for details.\n\n"
); );
}
} }
} }