Skip to content

Commit

Permalink
return "file deleted" instead of raising an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Aug 26, 2024
1 parent 4314094 commit 831098a
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 48 deletions.
130 changes: 83 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ rust-version = "1.63"

[dependencies]
crossbeam-channel = "0.5.12"
notify = "6.1.1"
#notify = "6.1.1"
notify = {git = "https://github.com/samuelcolvin/notify.git", branch = "keep-io-error"}
pyo3 = { version = "0.22.2", features = ["extension-module", "generate-import-lib"] }

[lib]
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ impl RustNotify {
}
}
Err(e) => {
// see https://github.com/samuelcolvin/watchfiles/issues/282
// if we have IO errors from files not found, we return "file deleted", rather than the error
if let NotifyErrorKind::Io(io_error) = &e.kind {
if io_error.kind() == IOErrorKind::NotFound {
changes_clone.lock().unwrap().extend(
e.paths
.iter()
.map(|p| (CHANGE_DELETED, p.to_string_lossy().to_string())),
);
return;
}
}
*error_clone.lock().unwrap() = Some(format!("error in underlying watcher: {}", e));
}
};
Expand Down

0 comments on commit 831098a

Please sign in to comment.