Don't auto create assets folder (#11218)

# Objective

- Don't automatically create an assets folder
- resolves #11208

## Solution

- Removes directory creation from file reader.
- Clearer panic when using file watcher and asset folder doesn't exist

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Nicola Papale <nicopap@users.noreply.github.com>
This commit is contained in:
Kyle 2024-01-08 16:45:26 -05:00 committed by GitHub
parent 371cd69d4b
commit 2847cc6933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 9 deletions

View file

@ -6,7 +6,6 @@ mod file_asset;
#[cfg(not(feature = "multi-threaded"))]
mod sync_file_asset;
use bevy_log::warn;
#[cfg(feature = "file_watcher")]
pub use file_watcher::*;
@ -45,12 +44,6 @@ 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());
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 }
}

View file

@ -43,7 +43,7 @@ impl<'a> AssetSourceId<'a> {
}
/// Returns [`None`] if this is [`AssetSourceId::Default`] and [`Some`] containing the
/// the name if this is [`AssetSourceId::Name`].
/// name if this is [`AssetSourceId::Name`].
pub fn as_str(&self) -> Option<&str> {
match self {
AssetSourceId::Default => None,
@ -486,7 +486,7 @@ impl AssetSource {
sender,
file_debounce_wait_time,
)
.unwrap(),
.expect("Failed to create file watcher"),
));
#[cfg(any(
not(feature = "file_watcher"),