Skip to content

Commit

Permalink
Fix load_folder for non-default Asset Sources (bevyengine#10121)
Browse files Browse the repository at this point in the history
# Objective

Fixes bevyengine#10120

## Solution

Assign the folder path source to loaded descendant asset paths in
`load_folder`
  • Loading branch information
cart authored and ameknite committed Nov 6, 2023
1 parent adb6a29 commit 44d0008
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ impl AssetServer {
let path = path.into().into_owned();

fn load_folder<'a>(
source: AssetSourceId<'static>,
path: &'a Path,
reader: &'a dyn AssetReader,
server: &'a AssetServer,
Expand All @@ -474,10 +475,12 @@ impl AssetServer {
let mut path_stream = reader.read_directory(path.as_ref()).await?;
while let Some(child_path) = path_stream.next().await {
if reader.is_directory(&child_path).await? {
load_folder(&child_path, reader, server, handles).await?;
load_folder(source.clone(), &child_path, reader, server, handles)
.await?;
} else {
let path = child_path.to_str().expect("Path should be a valid string.");
match server.load_untyped_async(AssetPath::parse(path)).await {
let asset_path = AssetPath::parse(path).with_source(source.clone());
match server.load_untyped_async(asset_path).await {
Ok(handle) => handles.push(handle),
// skip assets that cannot be loaded
Err(
Expand Down Expand Up @@ -519,7 +522,7 @@ impl AssetServer {
};

let mut handles = Vec::new();
match load_folder(path.path(), asset_reader, &server, &mut handles).await {
match load_folder(source.id(), path.path(), asset_reader, &server, &mut handles).await {
Ok(_) => server.send_asset_event(InternalAssetEvent::Loaded {
id,
loaded_asset: LoadedAsset::new_with_dependencies(
Expand Down

0 comments on commit 44d0008

Please sign in to comment.