Skip to content

Commit 15c03e4

Browse files
committed
inotify: watch parent folder instead of file directly
1 parent 50b908a commit 15c03e4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@ async fn main() -> anyhow::Result<()> {
8080
.into_make_service();
8181

8282
let inotify = {
83-
let meta = args.meta.clone();
83+
let meta = std::path::absolute(&args.meta)?;
84+
let meta_parent = match meta.parent() {
85+
Some(parent) => parent.to_path_buf(),
86+
None => anyhow::bail!(
87+
"Failed to watch for meta file changes. Parent folder could not be deteminated."
88+
),
89+
};
90+
8491
tokio::spawn(async move {
8592
let inotify = Inotify::init()?;
86-
inotify.watches().add(meta, WatchMask::CLOSE_WRITE | WatchMask::MOVED_TO)?;
93+
inotify
94+
.watches()
95+
.add(meta_parent, WatchMask::CLOSE_WRITE | WatchMask::MOVED_TO)?;
8796
let mut buf = [0; 1024];
8897
let mut stream = inotify.into_event_stream(&mut buf)?;
8998

0 commit comments

Comments
 (0)