This commit is contained in:
shishanyue 2025-06-21 15:35:04 +08:00
parent d4cf944576
commit 484d5c848d
2 changed files with 11 additions and 14 deletions

View File

@ -1574,7 +1574,7 @@ mod tests {
}
#[test]
fn load_folder() {
fn load_batch() {
// The particular usage of GatedReader in this test will cause deadlocking if running single-threaded
#[cfg(not(feature = "multi_threaded"))]
panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded");
@ -1619,7 +1619,7 @@ mod tests {
.register_asset_loader(CoolTextLoader);
let asset_server = app.world().resource::<AssetServer>().clone();
let handle: Handle<LoadedBatch> =
asset_server.load_batch(LoadBatchRequest::new(vec!["text"]));
asset_server.load_batch(LoadBatchRequest::new(vec!["text/*","b.cool.ron"]));
gate_opener.open(a_path);
gate_opener.open(b_path);
gate_opener.open(c_path);

View File

@ -944,7 +944,7 @@ impl AssetServer {
/// removed, added or moved. This includes files in subdirectories and moving, adding,
/// or removing complete subdirectories.
#[must_use = "not using the returned strong handle may result in the unexpected release of the assets"]
pub fn load_batch<'a>(&self, load_batch_request: LoadBatchRequest) -> Handle<LoadedBatch> {
pub fn load_batch(&self, load_batch_request: LoadBatchRequest) -> Handle<LoadedBatch> {
let handle = self.data.infos.write().create_loading_handle_untyped(
TypeId::of::<LoadedBatch>(),
core::any::type_name::<LoadedBatch>(),
@ -1012,16 +1012,13 @@ impl AssetServer {
let path = AssetPath::from_path_buf(path);
let source = match server.get_source(path.source()) {
Ok(s) => s,
Err(_) => {
error!(
"Failed to load {}. AssetSource {} does not exist",
path,
path.source()
);
continue;
}
let Ok(source) = server.get_source(path.source()) else {
error!(
"Failed to load {}. AssetSource {} does not exist",
path,
path.source()
);
return;
};
if let Err(err) =
@ -1040,7 +1037,7 @@ impl AssetServer {
id,
loaded_asset: LoadedAsset::new_with_dependencies(LoadedBatch { handles })
.into(),
})
});
})
.detach();
}