Update dependencies and enhance logging in memofs

- Bump versions of `clap` and `zerocopy` packages in Cargo.lock.
- Add `log` dependency to memofs Cargo.toml.
- Improve logging in the file watcher thread to capture errors and trace events, enhancing reliability and debugging capabilities.
This commit is contained in:
Joe 2026-01-29 11:37:21 -06:00
parent 9622753c24
commit d002c4e821
3 changed files with 50 additions and 17 deletions

19
Cargo.lock generated
View file

@ -279,18 +279,18 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.54" version = "4.5.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" checksum = "a75ca66430e33a14957acc24c5077b503e7d374151b2b4b3a10c83b4ceb4be0e"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
] ]
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.54" version = "4.5.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" checksum = "793207c7fa6300a0608d1080b858e5fdbe713cdc1c8db9fb17777d8a13e63df0"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"clap_lex 0.7.7", "clap_lex 0.7.7",
@ -402,7 +402,7 @@ dependencies = [
"anes", "anes",
"cast", "cast",
"ciborium", "ciborium",
"clap 4.5.54", "clap 4.5.56",
"criterion-plot 0.5.0", "criterion-plot 0.5.0",
"is-terminal", "is-terminal",
"itertools", "itertools",
@ -1448,6 +1448,7 @@ version = "0.3.1"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"fs-err", "fs-err",
"log",
"notify", "notify",
"serde", "serde",
"tempfile", "tempfile",
@ -3499,18 +3500,18 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.8.34" version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71ddd76bcebeed25db614f82bf31a9f4222d3fbba300e6fb6c00afa26cbd4d9d" checksum = "fdea86ddd5568519879b8187e1cf04e24fce28f7fe046ceecbce472ff19a2572"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.8.34" version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8187381b52e32220d50b255276aa16a084ec0a9017a0ca2152a1f55c539758d" checksum = "0c15e1b46eff7c6c91195752e0eeed8ef040e391cdece7c25376957d5f15df22"
dependencies = [ dependencies = [
"proc-macro2 1.0.106", "proc-macro2 1.0.106",
"quote 1.0.44", "quote 1.0.44",

View file

@ -17,6 +17,7 @@ homepage = "https://github.com/rojo-rbx/rojo/tree/master/memofs"
[dependencies] [dependencies]
crossbeam-channel = "0.5.15" crossbeam-channel = "0.5.15"
fs-err = "2.11.0" fs-err = "2.11.0"
log = "0.4"
notify = "4.0.18" notify = "4.0.18"
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }

View file

@ -24,26 +24,57 @@ impl StdBackend {
let (tx, rx) = crossbeam_channel::unbounded(); let (tx, rx) = crossbeam_channel::unbounded();
thread::spawn(move || { thread::spawn(move || {
log::trace!("File watcher thread started");
for event in notify_rx { for event in notify_rx {
match event { let send_result = match event {
DebouncedEvent::Create(path) => { DebouncedEvent::Create(path) => {
tx.send(VfsEvent::Create(path))?; tx.send(VfsEvent::Create(path))
} }
DebouncedEvent::Write(path) => { DebouncedEvent::Write(path) => {
tx.send(VfsEvent::Write(path))?; tx.send(VfsEvent::Write(path))
} }
DebouncedEvent::Remove(path) => { DebouncedEvent::Remove(path) => {
tx.send(VfsEvent::Remove(path))?; tx.send(VfsEvent::Remove(path))
} }
DebouncedEvent::Rename(from, to) => { DebouncedEvent::Rename(from, to) => {
tx.send(VfsEvent::Remove(from))?; tx.send(VfsEvent::Remove(from))
tx.send(VfsEvent::Create(to))?; .and_then(|_| tx.send(VfsEvent::Create(to)))
} }
_ => {} DebouncedEvent::Error(err, path) => {
log::error!(
"File watcher error: {:?} (path: {:?}). \
File watching is no longer reliable.",
err,
path
);
std::process::exit(1);
}
DebouncedEvent::Rescan => {
log::error!(
"File watcher requested rescan due to too many changes. \
File watching is no longer reliable."
);
std::process::exit(1);
}
// NoticeWrite and NoticeRemove are pre-debounce notifications, skip them
DebouncedEvent::NoticeWrite(_) | DebouncedEvent::NoticeRemove(_) => continue,
// Chmod events are not relevant for our purposes
DebouncedEvent::Chmod(_) => continue,
};
if let Err(err) = send_result {
log::error!(
"File watcher thread failed to send event: {}. \
File watching is no longer reliable.",
err
);
std::process::exit(1);
} }
} }
Result::<(), crossbeam_channel::SendError<VfsEvent>>::Ok(()) log::error!("File watcher thread has terminated unexpectedly.");
std::process::exit(1);
}); });
Self { Self {