Skip to content

Commit 933752a

Browse files
eckzmockersf
andauthored
Don't panic on temporary files in file watcher (#18462)
# Objective Fixes #18461 Apparently `RustRover` creates a temporary file with a tilde like `load_scene_example.scn.ron~` and at the moment of calling `.canonicalize()` the file does not exists anymore. ## Solution Not call `.unwrap()` and return `None` fixes the issue. ## Testing - `cargo ci`: OK - Tested the `scene` example with `file_watcher` feature and it works as expected. Co-authored-by: François Mockers <[email protected]>
1 parent 584c666 commit 933752a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_asset/src/io/file/file_watcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl FileWatcher {
3535
sender: Sender<AssetSourceEvent>,
3636
debounce_wait_time: Duration,
3737
) -> Result<Self, notify::Error> {
38-
let root = normalize_path(&path).canonicalize().unwrap();
38+
let root = normalize_path(&path).canonicalize()?;
3939
let watcher = new_asset_event_debouncer(
4040
path.clone(),
4141
debounce_wait_time,
@@ -262,7 +262,7 @@ impl FilesystemEventHandler for FileEventHandler {
262262
self.last_event = None;
263263
}
264264
fn get_path(&self, absolute_path: &Path) -> Option<(PathBuf, bool)> {
265-
let absolute_path = absolute_path.canonicalize().unwrap();
265+
let absolute_path = absolute_path.canonicalize().ok()?;
266266
Some(get_asset_path(&self.root, &absolute_path))
267267
}
268268

0 commit comments

Comments
 (0)