Skip to content

Commit b7785d1

Browse files
authored
Try #2318:
2 parents ac04c71 + bd1e264 commit b7785d1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/bevy_asset/src/asset_server.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ impl AssetServer {
236236
asset_path: AssetPath<'_>,
237237
force: bool,
238238
) -> Result<AssetPathId, AssetServerError> {
239-
let asset_loader = self.get_path_asset_loader(asset_path.path())?;
240239
let asset_path_id: AssetPathId = asset_path.get_id();
241240

242241
// load metadata and update source info. this is done in a scope to ensure we release the
@@ -280,6 +279,15 @@ impl AssetServer {
280279
source_info.load_state = LoadState::Failed;
281280
};
282281

282+
// get the according asset loader
283+
let asset_loader = match self.get_path_asset_loader(asset_path.path()) {
284+
Ok(loader) => loader,
285+
Err(err) => {
286+
set_asset_failed();
287+
return Err(err);
288+
}
289+
};
290+
283291
// load the asset bytes
284292
let bytes = match self.server.asset_io.load_path(asset_path.path()).await {
285293
Ok(bytes) => bytes,
@@ -708,7 +716,7 @@ mod test {
708716
_ => false,
709717
});
710718

711-
assert_eq!(asset_server.get_load_state(handle), LoadState::NotLoaded);
719+
assert_eq!(asset_server.get_load_state(handle), LoadState::Failed);
712720
}
713721

714722
#[test]

0 commit comments

Comments
 (0)