Merge branch 'dev'

This commit is contained in:
Filipe Rodrigues 2024-08-10 15:01:10 +01:00
commit 91f9eb3e2f
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
4 changed files with 50 additions and 8 deletions

View File

@ -1,3 +1,11 @@
# 0.1.6
# Minor
- `--watch` now ignores write events to files, and only updates once they are closed by the process.
This fixes half-written files being read by rules.
# 0.1.5
# Major

5
Cargo.lock generated
View File

@ -584,8 +584,7 @@ dependencies = [
[[package]]
name = "npath"
version = "0.1.0"
source = "sparse+https://gitea.filipejr.com/api/packages/zenithsiz/cargo/"
checksum = "07880f4197c50d48e4cd0e4a8f2d6807023d3297b6b9efd0d6335e31c21c88f5"
source = "git+https://github.com/gdzx/npath?rev=00acdd2974bb1682b6d1dcc6f0ea7cd54da42381#00acdd2974bb1682b6d1dcc6f0ea7cd54da42381"
[[package]]
name = "nu-ansi-term"
@ -1206,7 +1205,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "zbuild"
version = "0.1.5"
version = "0.1.6"
dependencies = [
"anyhow",
"async-broadcast",

View File

@ -4,7 +4,7 @@ edition = "2021"
name = "zbuild"
description = "Make-like build system"
license-file = "LICENSE-MIT"
version = "0.1.5"
version = "0.1.6"
repository = "https://github.com/zenithsiz/zbuild"
publish = ["filipejr"]
@ -19,7 +19,7 @@ futures = "0.3.29"
itertools = "0.12.0"
notify = "6.1.1"
notify-debouncer-full = "0.3.1"
npath = { version = "0.1.0", registry = "filipejr" }
npath = { git = "https://github.com/gdzx/npath", rev = "00acdd2974bb1682b6d1dcc6f0ea7cd54da42381" }
pin-project = "1.1.3"
serde = { version = "1.0.193", features = ["derive"] }
serde_yaml = "0.9.27"

View File

@ -89,7 +89,7 @@ impl<'s> Watcher<'s> {
#[expect(clippy::too_many_lines, reason = "TODO: Refactor")]
pub async fn watch_rebuild(mut self, builder: &Builder<'s>, rules: &Rules<'s>, ignore_missing: bool) {
let rev_deps = &self.rev_deps;
futures::join!(
futures::future::join(
async move {
self.builder_event_rx
.map(move |event| {
@ -148,6 +148,40 @@ impl<'s> Watcher<'s> {
tracing::trace!("Watcher task exited");
},
self.fs_event_stream
.filter(|event| {
#[expect(
clippy::match_same_arms,
reason = "It reads and is more easily modify-able like this"
)]
let allow = match event.event.kind {
notify::EventKind::Any => true,
notify::EventKind::Access(kind) => match kind {
notify::event::AccessKind::Any => true,
notify::event::AccessKind::Read => false,
notify::event::AccessKind::Open(_) => false,
notify::event::AccessKind::Close(mode) => match mode {
notify::event::AccessMode::Any => true,
notify::event::AccessMode::Execute => false,
notify::event::AccessMode::Read => false,
notify::event::AccessMode::Write => true,
notify::event::AccessMode::Other => true,
},
notify::event::AccessKind::Other => true,
},
notify::EventKind::Create(_) => true,
notify::EventKind::Modify(kind) => match kind {
notify::event::ModifyKind::Any => true,
notify::event::ModifyKind::Data(_) => false,
notify::event::ModifyKind::Metadata(_) => true,
notify::event::ModifyKind::Name(_) => true,
notify::event::ModifyKind::Other => true,
},
notify::EventKind::Remove(_) => true,
notify::EventKind::Other => true,
};
async move { allow }
})
.flat_map(|event| futures::stream::iter(event.event.paths))
.then(move |path| async move {
// Canonicalize the path
@ -218,7 +252,8 @@ impl<'s> Watcher<'s> {
tracing::trace!(?path, "Rebuilt all reverse dependencies");
})
.collect::<()>()
);
.collect::<()>(),
)
.await;
}
}