From 72321ca3c5a2634c33d218ef10c2c16bad8d5f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Maita?= <47983254+mnmaita@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:23:03 +0100 Subject: [PATCH] Update notify-debouncer-full requirement from 0.3.1 to 0.4.0 (#16133) # Objective - Supersedes #16126 ## Solution - Updated code in `file_watcher.rs` to fix breaking changes introduced in the new version. - Check changelog here: https://github.com/notify-rs/notify/blob/main/CHANGELOG.md#debouncer-full-040-2024-10-25. - Relevant PR with the breaking change: https://github.com/notify-rs/notify/pull/557. ## Testing - CI checks passing locally --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- crates/bevy_asset/Cargo.toml | 2 +- crates/bevy_asset/src/io/embedded/embedded_watcher.rs | 4 ++-- crates/bevy_asset/src/io/file/file_watcher.rs | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index b5cf075ab2..f596805b46 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -65,7 +65,7 @@ wasm-bindgen-futures = "0.4" js-sys = "0.3" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -notify-debouncer-full = { version = "0.3.1", optional = true } +notify-debouncer-full = { version = "0.4.0", optional = true } [dev-dependencies] bevy_core = { path = "../bevy_core", version = "0.15.0-dev" } diff --git a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs index dd863d7cf9..cc97eb3cda 100644 --- a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs +++ b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs @@ -5,7 +5,7 @@ use crate::io::{ }; use alloc::sync::Arc; use bevy_utils::{tracing::warn, Duration, HashMap}; -use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap}; +use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache}; use parking_lot::RwLock; use std::{ fs::File, @@ -18,7 +18,7 @@ use std::{ /// This watcher will watch for changes to the "source files", read the contents of changed files from the file system /// and overwrite the initial static bytes of the file embedded in the binary with the new dynamically loaded bytes. pub struct EmbeddedWatcher { - _watcher: Debouncer, + _watcher: Debouncer, } impl EmbeddedWatcher { diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index 1da55fae97..bb4cf109c3 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -9,9 +9,9 @@ use notify_debouncer_full::{ notify::{ self, event::{AccessKind, AccessMode, CreateKind, ModifyKind, RemoveKind, RenameMode}, - RecommendedWatcher, RecursiveMode, Watcher, + RecommendedWatcher, RecursiveMode, }, - DebounceEventResult, Debouncer, FileIdMap, + DebounceEventResult, Debouncer, RecommendedCache, }; use std::path::{Path, PathBuf}; @@ -21,7 +21,7 @@ use std::path::{Path, PathBuf}; /// This introduces a small delay in processing events, but it helps reduce event duplicates. A small delay is also necessary /// on some systems to avoid processing a change event before it has actually been applied. pub struct FileWatcher { - _watcher: Debouncer, + _watcher: Debouncer, } impl FileWatcher { @@ -73,7 +73,7 @@ pub(crate) fn new_asset_event_debouncer( root: PathBuf, debounce_wait_time: Duration, mut handler: impl FilesystemEventHandler, -) -> Result, notify::Error> { +) -> Result, notify::Error> { let root = super::get_base_path().join(root); let mut debouncer = new_debouncer( debounce_wait_time, @@ -245,8 +245,7 @@ pub(crate) fn new_asset_event_debouncer( } }, )?; - debouncer.watcher().watch(&root, RecursiveMode::Recursive)?; - debouncer.cache().add_root(&root, RecursiveMode::Recursive); + debouncer.watch(&root, RecursiveMode::Recursive)?; Ok(debouncer) }