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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Martín Maita 2024-10-28 23:23:03 +01:00 committed by GitHub
parent 05d90686fc
commit 72321ca3c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

View file

@ -65,7 +65,7 @@ wasm-bindgen-futures = "0.4"
js-sys = "0.3" js-sys = "0.3"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [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] [dev-dependencies]
bevy_core = { path = "../bevy_core", version = "0.15.0-dev" } bevy_core = { path = "../bevy_core", version = "0.15.0-dev" }

View file

@ -5,7 +5,7 @@ use crate::io::{
}; };
use alloc::sync::Arc; use alloc::sync::Arc;
use bevy_utils::{tracing::warn, Duration, HashMap}; 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 parking_lot::RwLock;
use std::{ use std::{
fs::File, 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 /// 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. /// and overwrite the initial static bytes of the file embedded in the binary with the new dynamically loaded bytes.
pub struct EmbeddedWatcher { pub struct EmbeddedWatcher {
_watcher: Debouncer<RecommendedWatcher, FileIdMap>, _watcher: Debouncer<RecommendedWatcher, RecommendedCache>,
} }
impl EmbeddedWatcher { impl EmbeddedWatcher {

View file

@ -9,9 +9,9 @@ use notify_debouncer_full::{
notify::{ notify::{
self, self,
event::{AccessKind, AccessMode, CreateKind, ModifyKind, RemoveKind, RenameMode}, event::{AccessKind, AccessMode, CreateKind, ModifyKind, RemoveKind, RenameMode},
RecommendedWatcher, RecursiveMode, Watcher, RecommendedWatcher, RecursiveMode,
}, },
DebounceEventResult, Debouncer, FileIdMap, DebounceEventResult, Debouncer, RecommendedCache,
}; };
use std::path::{Path, PathBuf}; 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 /// 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. /// on some systems to avoid processing a change event before it has actually been applied.
pub struct FileWatcher { pub struct FileWatcher {
_watcher: Debouncer<RecommendedWatcher, FileIdMap>, _watcher: Debouncer<RecommendedWatcher, RecommendedCache>,
} }
impl FileWatcher { impl FileWatcher {
@ -73,7 +73,7 @@ pub(crate) fn new_asset_event_debouncer(
root: PathBuf, root: PathBuf,
debounce_wait_time: Duration, debounce_wait_time: Duration,
mut handler: impl FilesystemEventHandler, mut handler: impl FilesystemEventHandler,
) -> Result<Debouncer<RecommendedWatcher, FileIdMap>, notify::Error> { ) -> Result<Debouncer<RecommendedWatcher, RecommendedCache>, notify::Error> {
let root = super::get_base_path().join(root); let root = super::get_base_path().join(root);
let mut debouncer = new_debouncer( let mut debouncer = new_debouncer(
debounce_wait_time, debounce_wait_time,
@ -245,8 +245,7 @@ pub(crate) fn new_asset_event_debouncer(
} }
}, },
)?; )?;
debouncer.watcher().watch(&root, RecursiveMode::Recursive)?; debouncer.watch(&root, RecursiveMode::Recursive)?;
debouncer.cache().add_root(&root, RecursiveMode::Recursive);
Ok(debouncer) Ok(debouncer)
} }