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 <jp@bloomdigital.to>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
super-saturn 2024-12-29 14:43:42 -05:00 committed by François Mockers
parent e6256e77cd
commit f8bd5144a5
2 changed files with 4 additions and 4 deletions

View File

@ -26,13 +26,13 @@ pub struct FileWatcher {
impl FileWatcher {
pub fn new(
root: PathBuf,
path: PathBuf,
sender: Sender<AssetSourceEvent>,
debounce_wait_time: Duration,
) -> Result<Self, notify::Error> {
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,

View File

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