Added canary asset

This commit is contained in:
Joshua Barretto 2023-01-18 22:01:00 +00:00
parent a537d52f48
commit 44f4dcc6f7
4 changed files with 23 additions and 1 deletions

1
.gitattributes vendored
View File

@ -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

Binary file not shown.

View File

@ -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,

View File

@ -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() {