From 2dcf6bcfd74b2ed49a189b79eefc2f32eb6da90c Mon Sep 17 00:00:00 2001 From: super-saturn <127321359+super-saturn@users.noreply.github.com> Date: Sun, 29 Dec 2024 14:43:42 -0500 Subject: [PATCH] Fix path checking for FileWatcher for virtual workspace projects (#16958) # Objective Fixes #16879 ## Solution Moved the construction of the root path of the assets folder out of `FileWatcher::new()` and into `source.rs`, as the path is checked there with `path.exists()` and fails in certain configurations eg., virtual workspaces. ## Testing Applied fix to a private fork and tested against both standard project setups and virtual workspaces. Works without issue on both. Have tested under macOS and Arch Linux. --------- Co-authored-by: JP Stringham Co-authored-by: Alice Cecile --- crates/bevy_asset/src/io/file/file_watcher.rs | 6 +++--- crates/bevy_asset/src/io/source.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index a7024a4400..0f10b493cd 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -26,13 +26,13 @@ pub struct FileWatcher { impl FileWatcher { pub fn new( - root: PathBuf, + path: PathBuf, sender: Sender, debounce_wait_time: Duration, ) -> Result { - let root = normalize_path(super::get_base_path().join(root).as_path()); + let root = normalize_path(&path); let watcher = new_asset_event_debouncer( - root.clone(), + path.clone(), debounce_wait_time, FileEventHandler { root, diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index c0bab2037f..f1b4455179 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -531,7 +531,7 @@ impl AssetSource { not(target_os = "android") ))] { - let path = std::path::PathBuf::from(path.clone()); + let path = super::file::get_base_path().join(path.clone()); if path.exists() { Some(Box::new( super::file::FileWatcher::new(