diff --git a/crates/bevy_asset/src/io/file/file_asset.rs b/crates/bevy_asset/src/io/file/file_asset.rs index 58ae546e7f..bbbf9f9215 100644 --- a/crates/bevy_asset/src/io/file/file_asset.rs +++ b/crates/bevy_asset/src/io/file/file_asset.rs @@ -38,7 +38,7 @@ impl AssetReader for FileAssetReader { let full_path = self.root_path.join(path); File::open(&full_path).await.map_err(|e| { if e.kind() == std::io::ErrorKind::NotFound { - AssetReaderError::NotFound(full_path) + AssetReaderError::NotFound(full_path.to_path_buf().to_str().unwrap().to_owned()) } else { e.into() } @@ -50,7 +50,7 @@ impl AssetReader for FileAssetReader { let full_path = self.root_path.join(meta_path); File::open(&full_path).await.map_err(|e| { if e.kind() == std::io::ErrorKind::NotFound { - AssetReaderError::NotFound(full_path) + AssetReaderError::NotFound(full_path.to_path_buf().to_str().unwrap().to_owned()) } else { e.into() } @@ -92,7 +92,9 @@ impl AssetReader for FileAssetReader { } Err(e) => { if e.kind() == std::io::ErrorKind::NotFound { - Err(AssetReaderError::NotFound(full_path)) + Err(AssetReaderError::NotFound( + full_path.to_path_buf().to_str().unwrap().to_owned(), + )) } else { Err(e.into()) } @@ -102,9 +104,9 @@ impl AssetReader for FileAssetReader { async fn is_directory<'a>(&'a self, path: &'a Path) -> Result { let full_path = self.root_path.join(path); - let metadata = full_path - .metadata() - .map_err(|_e| AssetReaderError::NotFound(path.to_owned()))?; + let metadata = full_path.metadata().map_err(|_e| { + AssetReaderError::NotFound(path.to_path_buf().to_str().unwrap().to_owned()) + })?; Ok(metadata.file_type().is_dir()) } } diff --git a/crates/bevy_asset/src/io/memory.rs b/crates/bevy_asset/src/io/memory.rs index 4c56057ff9..220f73ee90 100644 --- a/crates/bevy_asset/src/io/memory.rs +++ b/crates/bevy_asset/src/io/memory.rs @@ -294,7 +294,9 @@ impl AssetReader for MemoryAssetReader { data, bytes_read: 0, }) - .ok_or_else(|| AssetReaderError::NotFound(path.to_path_buf())) + .ok_or_else(|| { + AssetReaderError::NotFound(path.to_path_buf().to_str().unwrap().to_owned()) + }) } async fn read_meta<'a>(&'a self, path: &'a Path) -> Result { @@ -304,7 +306,9 @@ impl AssetReader for MemoryAssetReader { data, bytes_read: 0, }) - .ok_or_else(|| AssetReaderError::NotFound(path.to_path_buf())) + .ok_or_else(|| { + AssetReaderError::NotFound(path.to_path_buf().to_str().unwrap().to_owned()) + }) } async fn read_directory<'a>( @@ -317,7 +321,9 @@ impl AssetReader for MemoryAssetReader { let stream: Box = Box::new(DirStream::new(dir)); stream }) - .ok_or_else(|| AssetReaderError::NotFound(path.to_path_buf())) + .ok_or_else(|| { + AssetReaderError::NotFound(path.to_path_buf().to_str().unwrap().to_owned()) + }) } async fn is_directory<'a>(&'a self, path: &'a Path) -> Result { diff --git a/crates/bevy_asset/src/io/mod.rs b/crates/bevy_asset/src/io/mod.rs index aa7256bbd9..a9b86058ed 100644 --- a/crates/bevy_asset/src/io/mod.rs +++ b/crates/bevy_asset/src/io/mod.rs @@ -38,8 +38,8 @@ use thiserror::Error; #[derive(Error, Debug, Clone)] pub enum AssetReaderError { /// Path not found. - #[error("Path not found: {}", _0.display())] - NotFound(PathBuf), + #[error("Path not found: {}", _0)] + NotFound(alloc::string::String), /// Encountered an I/O error while loading an asset. #[error("Encountered an I/O error while loading asset: {0}")] diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index da439f56f5..d9820f1178 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -7,7 +7,7 @@ use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec}; use async_lock::RwLockReadGuardArc; use core::{pin::Pin, task::Poll}; use futures_io::AsyncRead; -use std::path::Path; +use std::path::{Path, PathBuf}; use tracing::trace; use super::{AsyncSeekForward, ErasedAssetReader}; @@ -43,9 +43,9 @@ impl ProcessorGatedReader { path: &AssetPath<'static>, ) -> Result, AssetReaderError> { let infos = self.processor_data.asset_infos.read().await; - let info = infos - .get(path) - .ok_or_else(|| AssetReaderError::NotFound(path.path().to_owned()))?; + let info = infos.get(path).ok_or_else(|| { + AssetReaderError::NotFound(PathBuf::from(path.path()).to_str().unwrap().to_owned()) + })?; Ok(info.file_transaction_lock.read_arc().await) } } @@ -61,7 +61,9 @@ impl AssetReader for ProcessorGatedReader { match process_result { ProcessStatus::Processed => {} ProcessStatus::Failed | ProcessStatus::NonExistent => { - return Err(AssetReaderError::NotFound(path.to_owned())); + return Err(AssetReaderError::NotFound( + path.to_path_buf().to_str().unwrap().to_owned(), + )); } } trace!("Processing finished with {asset_path}, reading {process_result:?}",); @@ -81,7 +83,9 @@ impl AssetReader for ProcessorGatedReader { match process_result { ProcessStatus::Processed => {} ProcessStatus::Failed | ProcessStatus::NonExistent => { - return Err(AssetReaderError::NotFound(path.to_owned())); + return Err(AssetReaderError::NotFound( + path.to_path_buf().to_str().unwrap().to_owned(), + )); } } trace!("Processing finished with {process_result:?}, reading meta for {asset_path}",);