diff --git a/common/assets/src/lib.rs b/common/assets/src/lib.rs index 4fe6df40eb..c85387347f 100644 --- a/common/assets/src/lib.rs +++ b/common/assets/src/lib.rs @@ -129,7 +129,7 @@ pub trait AssetCombined: AssetExt { /// Load combined table without hot-reload support fn load_and_combine_static(specifier: &str) -> Result, Error> { - Self::load_and_combine(ASSETS.filesystem_cache(), specifier) + Self::load_and_combine(ASSETS.non_reloading_cache(), specifier) } #[track_caller] @@ -149,7 +149,7 @@ pub trait AssetCombined: AssetExt { /// Load combined table without hot-reload support, panic on error #[track_caller] fn load_expect_combined_static(specifier: &str) -> AssetHandle { - Self::load_expect_combined(ASSETS.filesystem_cache(), specifier) + Self::load_expect_combined(ASSETS.non_reloading_cache(), specifier) } } @@ -157,7 +157,6 @@ pub trait AssetCombined: AssetExt { pub trait CacheCombined<'a> { fn load_and_combine( self, - // reloading_cache: AnyCache, id: &str, ) -> Result<&'a assets_manager::Handle, Error>; } @@ -188,20 +187,14 @@ impl AssetExt for T { impl<'a> CacheCombined<'a> for AnyCache<'a> { fn load_and_combine( self, - // reloading_cache: AnyCache, specifier: &str, ) -> Result<&'a assets_manager::Handle, Error> { #[cfg(feature = "plugins")] { - self.get_cached(specifier).map_or_else( - || { - tracing::info!("combine {specifier}"); - let data: Result = - ASSETS.combine(self, |cache: AnyCache| cache.load_owned::(specifier)); - data.map(|data| self.get_or_insert(specifier, data)) - }, - Ok, - ) + tracing::info!("combine {specifier}"); + let data: Result = + ASSETS.combine(self, |cache: AnyCache| cache.load_owned::(specifier)); + data.map(|data| self.get_or_insert(specifier, data)) } #[cfg(not(feature = "plugins"))] { @@ -210,7 +203,6 @@ impl<'a> CacheCombined<'a> for AnyCache<'a> { } } -// this function bypasses hot-reloading! impl AssetCombined for T { fn load_and_combine( reloading_cache: AnyCache<'static>, diff --git a/common/assets/src/plugin_cache.rs b/common/assets/src/plugin_cache.rs index 06f51ec98f..048229656b 100644 --- a/common/assets/src/plugin_cache.rs +++ b/common/assets/src/plugin_cache.rs @@ -133,8 +133,11 @@ impl CombinedCache { } #[doc(hidden)] - // when not using a compound - pub(crate) fn filesystem_cache(&self) -> AnyCache<'_> { self.0.raw_source().fs.as_any_cache() } + // Provide a cache to the "combine_static" functions as they omit + // wrapping in a Compound (which enables hot-reload) + pub(crate) fn non_reloading_cache(&self) -> AnyCache<'_> { + self.0.raw_source().fs.as_any_cache() + } /// Combine objects from filesystem and plugins pub fn combine( @@ -200,6 +203,7 @@ impl CombinedCache { // Just forward these methods to the cache #[inline] + #[cfg(feature = "hot-reloading")] pub fn enhance_hot_reloading(&'static self) { self.0.enhance_hot_reloading(); } #[inline]