Skip to content

Commit

Permalink
don't ignore some EventKind::Modify (#9767)
Browse files Browse the repository at this point in the history
# Objective

- File modification don't trigger hot reload on macOS 

## Solution

-
[`EventKind::Modify`](https://docs.rs/notify/latest/notify/event/enum.EventKind.html#variant.Modify)
can have several reasons
-
[`ModifyKind::Any`](https://docs.rs/notify/latest/notify/event/enum.ModifyKind.html)
was used to react to change events, and later ModifyKind::Name for file
name change. It left other variants of change ignored (`Data`,
`Metadata`, `Other`)
- move the modification handling after the rename so that it handles all
other variants
  • Loading branch information
mockersf committed Sep 13, 2023
1 parent 8fa500d commit 72b8f47
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/bevy_asset/src/io/file/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ impl FileWatcher {
let (path, _) = get_asset_path(&owned_root, &event.paths[0]);
sender.send(AssetSourceEvent::AddedFolder(path)).unwrap();
}
notify::EventKind::Modify(ModifyKind::Any) => {
let (path, is_meta) =
get_asset_path(&owned_root, &event.paths[0]);
if event.paths[0].is_dir() {
// modified folder means nothing in this case
} else if is_meta {
sender.send(AssetSourceEvent::ModifiedMeta(path)).unwrap();
} else {
sender.send(AssetSourceEvent::ModifiedAsset(path)).unwrap();
};
}
notify::EventKind::Access(AccessKind::Close(AccessMode::Write)) => {
let (path, is_meta) =
get_asset_path(&owned_root, &event.paths[0]);
Expand Down Expand Up @@ -134,6 +123,17 @@ impl FileWatcher {
}
}
}
notify::EventKind::Modify(_) => {
let (path, is_meta) =
get_asset_path(&owned_root, &event.paths[0]);
if event.paths[0].is_dir() {
// modified folder means nothing in this case
} else if is_meta {
sender.send(AssetSourceEvent::ModifiedMeta(path)).unwrap();
} else {
sender.send(AssetSourceEvent::ModifiedAsset(path)).unwrap();
};
}
notify::EventKind::Remove(RemoveKind::File) => {
let (path, is_meta) =
get_asset_path(&owned_root, &event.paths[0]);
Expand Down

0 comments on commit 72b8f47

Please sign in to comment.