Skip to content

Commit

Permalink
Update notify-debouncer-full requirement from 0.3.1 to 0.4.0 (#16133)
Browse files Browse the repository at this point in the history
# 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:
notify-rs/notify#557.

## Testing

- CI checks passing locally

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
mnmaita and dependabot[bot] authored Oct 28, 2024
1 parent 05d9068 commit 72321ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/io/embedded/embedded_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<RecommendedWatcher, FileIdMap>,
_watcher: Debouncer<RecommendedWatcher, RecommendedCache>,
}

impl EmbeddedWatcher {
Expand Down
11 changes: 5 additions & 6 deletions crates/bevy_asset/src/io/file/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<RecommendedWatcher, FileIdMap>,
_watcher: Debouncer<RecommendedWatcher, RecommendedCache>,
}

impl FileWatcher {
Expand Down Expand Up @@ -73,7 +73,7 @@ pub(crate) fn new_asset_event_debouncer(
root: PathBuf,
debounce_wait_time: Duration,
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 mut debouncer = new_debouncer(
debounce_wait_time,
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 72321ca

Please sign in to comment.