register_tar with the cache object

This commit is contained in:
Christof Petig 2023-10-14 23:07:31 +02:00
parent 12ee21a289
commit 3a6d94bd3c
2 changed files with 11 additions and 9 deletions

View File

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

View File

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