From 46cbb8f781e644065e5c472a115dfe59426e545c Mon Sep 17 00:00:00 2001 From: Michael Leandersson Date: Fri, 17 Nov 2023 23:06:08 +0100 Subject: [PATCH] Do not panic when failing to create assets folder (#10613) (#10614) # Objective - Allow bevy applications that does not have any assets folder to start from a read-only directory. (typically installed to a systems folder) Fixes #10613 ## Solution - warn instead of panic when assets folder creation fails. --- crates/bevy_asset/src/io/file/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/bevy_asset/src/io/file/mod.rs b/crates/bevy_asset/src/io/file/mod.rs index aae016df3b..63a28cbb96 100644 --- a/crates/bevy_asset/src/io/file/mod.rs +++ b/crates/bevy_asset/src/io/file/mod.rs @@ -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::*; @@ -44,12 +45,12 @@ impl FileAssetReader { /// See `get_base_path` below. pub fn new>(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 } }