Skip to content

Commit

Permalink
Do not panic when failing to create assets folder (#10613)
Browse files Browse the repository at this point in the history
# Objective

- Allow bevy applications that does not have any
  assets folder to start from a read-only directory.
  (typically installed to a systems folder)

## Solution

- warn instead of panic when assets folder creation
  fails.
  • Loading branch information
tripokey committed Nov 17, 2023
1 parent 0c9f265 commit f6e6b10
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod file_asset;
#[cfg(not(feature = "multi-threaded"))]
mod sync_file_asset;

use bevy_log::warn;
#[cfg(feature = "file_watcher")]
pub use file_watcher::*;

Expand Down Expand Up @@ -44,12 +45,12 @@ impl FileAssetReader {
/// See `get_base_path` below.
pub fn new<P: AsRef<Path>>(path: P) -> Self {
let root_path = Self::get_base_path().join(path.as_ref());
std::fs::create_dir_all(&root_path).unwrap_or_else(|e| {
panic!(
if let Err(e) = std::fs::create_dir_all(&root_path) {
warn!(
"Failed to create root directory {:?} for file asset reader: {:?}",
root_path, e
)
});
);
}
Self { root_path }
}

Expand Down

0 comments on commit f6e6b10

Please sign in to comment.