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 <mcanders1@gmail.com>
This commit is contained in:
François 2023-10-26 23:32:12 +02:00 committed by GitHub
parent c81e2bd586
commit e5b3cc45ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;