From e5b3cc45bab6cba4b15dba0edf13a3a1baaa854f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 26 Oct 2023 23:32:12 +0200 Subject: [PATCH] Assets: fix first hot reloading (#9804) # Objective - Hot reloading doesn't work the first time it is used ## Solution - Currently, Bevy processor: 1. Create the `imported_assets` folder 2. Setup a watcher on it 3. Clear empty folders, so the `imported_assets` folder is deleted 4. Recreate the `imported_assets` folder and add all the imported assets - On a first run without an existing `imported_assets` with some content, hot reloading won't work as step 3 breaks the file watcher - This PR stops the empty root folder from being deleted - Also don't setup the processor internal asset server for file watching, freeing up a thread --------- Co-authored-by: Carter Anderson --- crates/bevy_asset/src/processor/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index 4e5b2a878a..55f136f252 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -506,7 +506,7 @@ impl AssetProcessor { .await? && contains_files; } - if !contains_files { + if !contains_files && path.parent().is_some() { if let Some(writer) = clean_empty_folders_writer { // it is ok for this to fail as it is just a cleanup job. let _ = writer.remove_empty_directory(&path).await;