mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
register_tar with the cache object
This commit is contained in:
parent
12ee21a289
commit
3a6d94bd3c
@ -25,7 +25,6 @@ mod fs;
|
||||
mod plugin_cache;
|
||||
#[cfg(feature = "plugins")] mod tar_source;
|
||||
mod walk;
|
||||
pub use plugin_cache::register_tar;
|
||||
pub use walk::{walk_tree, Walk};
|
||||
|
||||
lazy_static! {
|
||||
@ -36,6 +35,9 @@ lazy_static! {
|
||||
#[cfg(feature = "hot-reloading")]
|
||||
pub fn start_hot_reloading() { ASSETS.enhance_hot_reloading(); }
|
||||
|
||||
// register a new plugin
|
||||
pub fn register_tar(path: PathBuf) -> std::io::Result<()> { ASSETS.register_tar(path) }
|
||||
|
||||
pub type AssetHandle<T> = assets_manager::Handle<'static, T>;
|
||||
pub type AssetGuard<T> = assets_manager::AssetGuard<'static, T>;
|
||||
pub type AssetDirHandle<T> = assets_manager::DirHandle<'static, T>;
|
||||
|
@ -18,14 +18,6 @@ lazy_static! {
|
||||
static ref PLUGIN_LIST: RwLock<Vec<PluginEntry>> = RwLock::new(Vec::new());
|
||||
}
|
||||
|
||||
pub fn register_tar(path: PathBuf) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let tar_source = Tar::from_path(&path)?;
|
||||
println!("Tar {:?} {:?}", path, tar_source);
|
||||
let cache = AssetCache::with_source(tar_source);
|
||||
PLUGIN_LIST.write()?.push(PluginEntry { path, cache });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The source combining filesystem and plugins (typically used via
|
||||
/// CombinedCache)
|
||||
#[derive(Debug, Clone)]
|
||||
@ -139,6 +131,14 @@ impl CombinedCache {
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub fn register_tar(&self, path: PathBuf) -> std::io::Result<()> {
|
||||
let tar_source = Tar::from_path(&path)?;
|
||||
println!("Tar {:?} {:?}", path, tar_source);
|
||||
let cache = AssetCache::with_source(tar_source);
|
||||
PLUGIN_LIST.write().unwrap().push(PluginEntry { path, cache });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for CombinedCache {
|
||||
|
Loading…
Reference in New Issue
Block a user