mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/canary' into 'master'
Added canary asset See merge request veloren/veloren!3770
This commit is contained in:
commit
da9cd79973
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9,6 +9,7 @@
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.obj filter=lfs diff=lfs merge=lfs -text
|
||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||
*.canary filter=lfs diff=lfs merge=lfs -text
|
||||
assets/world/map/*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
*.ron gitlab-language=rust
|
||||
|
BIN
assets/common/canary.canary
(Stored with Git LFS)
Normal file
BIN
assets/common/canary.canary
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, io};
|
||||
use std::{borrow::Cow, fs, io};
|
||||
|
||||
use assets_manager::{
|
||||
hot_reloading::{DynUpdateSender, EventSender, FsWatcherBuilder},
|
||||
@ -23,6 +23,18 @@ impl FileSystem {
|
||||
.ok()
|
||||
});
|
||||
|
||||
let canary = fs::read_to_string(super::ASSETS_PATH.join("common").join("canary.canary"))
|
||||
.map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to load canary asset: {}", e),
|
||||
)
|
||||
})?;
|
||||
|
||||
if !canary.starts_with("VELOREN_CANARY_MAGIC") {
|
||||
panic!("Canary asset `canary.canary` was present but did not contain the expected data. This *heavily* implies that you've not correctly set up Git LFS (Large File Storage). Visit `https://book.veloren.net/contributors/development-tools.html#git-lfs` for more information about setting up Git LFS.");
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
default,
|
||||
override_dir,
|
||||
|
@ -305,6 +305,12 @@ mod tests {
|
||||
use std::{ffi::OsStr, fs::File};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[test]
|
||||
fn load_canary() {
|
||||
// Loading the asset cache will automatically cause the canary to load
|
||||
let _ = *super::ASSETS;
|
||||
}
|
||||
|
||||
/// Fail unless all `.ron` asset files successfully parse to `ron::Value`.
|
||||
#[test]
|
||||
fn parse_all_ron_files_to_value() {
|
||||
|
@ -1,10 +1,4 @@
|
||||
use std::{
|
||||
env,
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
use std::{env, fs::File, io::Write, path::Path, process::Command};
|
||||
|
||||
fn main() {
|
||||
// If these env variables exist then we are building on nix, use them as hash
|
||||
@ -52,38 +46,6 @@ fn main() {
|
||||
Err(e) => panic!("failed to retrieve current git commit hash: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
// Check if git-lfs is working
|
||||
if env::var("DISABLE_GIT_LFS_CHECK").is_err() && cfg!(not(feature = "no-assets")) {
|
||||
let asset_path: PathBuf = ["..", "assets", "voxygen", "background", "bg_main.jpg"]
|
||||
.iter()
|
||||
.collect();
|
||||
let asset_file = match File::open(&asset_path) {
|
||||
Ok(file) => file,
|
||||
Err(e) => panic!(
|
||||
"failed to open asset file {}: {}",
|
||||
asset_path.to_str().unwrap(),
|
||||
e
|
||||
),
|
||||
};
|
||||
const LFS_MARKER: &[u8] = b"version https://git-lfs.github.com/spec/";
|
||||
let mut buffer = Vec::new();
|
||||
let bytes_read = asset_file
|
||||
.take(LFS_MARKER.len() as u64)
|
||||
.read_to_end(&mut buffer)
|
||||
.expect("failed to read asset file");
|
||||
|
||||
if bytes_read == LFS_MARKER.len() && buffer == LFS_MARKER {
|
||||
panic!(
|
||||
"\n\nGit Large File Storage (git-lfs) has not been set up correctly.\n\
|
||||
Most common reasons:\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 The github mirror does not support lfs.\n\
|
||||
See the book at https://book.veloren.net/ for details.\n\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_hash_file(hash: &str) {
|
||||
|
@ -86,9 +86,6 @@
|
||||
pkgConfig = common: let
|
||||
inherit (common) pkgs;
|
||||
veloren-common-ov = {
|
||||
# Disable `git-lfs` check here since we check it ourselves
|
||||
# We have to include the command output here, otherwise Nix won't run it
|
||||
DISABLE_GIT_LFS_CHECK = true;
|
||||
# We don't add in any information here because otherwise anything
|
||||
# that depends on common will be recompiled. We will set these in
|
||||
# our wrapper instead.
|
||||
|
Loading…
Reference in New Issue
Block a user