From e007e72fc974d11e845bcce7dd6b6c535481fc57 Mon Sep 17 00:00:00 2001 From: zztkm <33755694+zztkm@users.noreply.github.com.> Date: Sat, 31 Jan 2026 02:33:08 +0000 Subject: [PATCH 1/2] =?UTF-8?q?serve=20=E3=82=B3=E3=83=9E=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=81=A7=20ls=20=E5=AE=9F=E8=A1=8C=E6=99=82=E3=81=AE?= =?UTF-8?q?=E8=AA=A4=E6=A4=9C=E7=9F=A5=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit notify-debouncer-mini から notify-debouncer-full に移行し、 EventKind::Access を除外することで、ls コマンドによる atime 更新を ファイル変更と誤検知しないようにした。 Co-Authored-By: Claude Opus 4.5 --- Cargo.lock | 137 ++++++++++------------------------------ Cargo.toml | 4 +- src/subcommand_serve.rs | 23 +++++-- 3 files changed, 54 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f164f5..c985c9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,15 +257,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -434,6 +425,15 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "file-id" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fc6a637b6dc58414714eddd9170ff187ecb0933d4c7024d1abbd23a3cc26e9" +dependencies = [ + "windows-sys 0.60.2", +] + [[package]] name = "filetime" version = "0.2.26" @@ -867,11 +867,11 @@ dependencies = [ [[package]] name = "inotify" -version = "0.9.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.10.0", "inotify-sys", "libc", ] @@ -1057,18 +1057,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.1.0" @@ -1076,6 +1064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", + "log", "wasi", "windows-sys 0.61.2", ] @@ -1088,32 +1077,42 @@ checksum = "fe77e710319d3ff009f93efc433d879e80e6336f5b87ace6d6db7ca5951085c3" [[package]] name = "notify" -version = "6.1.1" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" dependencies = [ "bitflags 2.10.0", - "crossbeam-channel", - "filetime", "fsevent-sys", "inotify", "kqueue", "libc", "log", - "mio 0.8.11", + "mio", + "notify-types", "walkdir", - "windows-sys 0.48.0", + "windows-sys 0.60.2", ] [[package]] -name = "notify-debouncer-mini" -version = "0.4.1" +name = "notify-debouncer-full" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" +checksum = "d2d88b1a7538054351c8258338df7c931a590513fb3745e8c15eb9ff4199b8d1" dependencies = [ - "crossbeam-channel", + "file-id", "log", "notify", + "notify-types", + "walkdir", +] + +[[package]] +name = "notify-types" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a" +dependencies = [ + "bitflags 2.10.0", ] [[package]] @@ -1944,7 +1943,7 @@ checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ "bytes", "libc", - "mio 1.1.0", + "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -2208,7 +2207,7 @@ dependencies = [ "markdown", "noargs", "notify", - "notify-debouncer-mini", + "notify-debouncer-full", "ramhorns", "self_update", "serde", @@ -2355,15 +2354,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -2400,21 +2390,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -2448,12 +2423,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -2466,12 +2435,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -2484,12 +2447,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2514,12 +2471,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -2532,12 +2483,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -2550,12 +2495,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -2568,12 +2507,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index fe5a111..368659e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ glob = "0.3.3" gray_matter = "0.2" markdown = "1.0.0" noargs = "0.4.1" -notify = "6.0" -notify-debouncer-mini = "0.4" +notify = "8.0" +notify-debouncer-full = "0.5" ramhorns = "0.14" self_update = { version = "0.41", default-features = false, features = ["archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate", "rustls"] } serde = { version = "1.0", features = ["derive"] } diff --git a/src/subcommand_serve.rs b/src/subcommand_serve.rs index 17906bd..675d82b 100644 --- a/src/subcommand_serve.rs +++ b/src/subcommand_serve.rs @@ -6,7 +6,8 @@ use axum::{ middleware::{self, Next}, response::Response, }; -use notify_debouncer_mini::{DebounceEventResult, new_debouncer, notify::*}; +use notify::event::EventKind; +use notify_debouncer_full::{new_debouncer, notify::RecursiveMode, DebounceEventResult}; use std::{ net::SocketAddr, path::{Path, PathBuf}, @@ -130,12 +131,23 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc>) -> Result<() // デバウンサーを作成(300ms の遅延) let mut debouncer = new_debouncer( Duration::from_millis(300), + None, move |res: DebounceEventResult| match res { Ok(events) => { - // dist ディレクトリ以外のファイルが変更された場合のみ再ビルド - let should_rebuild = events - .iter() - .any(|event| !event.path.starts_with(&dist_path)); + let should_rebuild = events.iter().any(|debounced_event| { + let path = match debounced_event.paths.first() { + Some(p) => p, + None => return false, + }; + + // dist ディレクトリ以下は無視 + if path.starts_with(&dist_path) { + return false; + } + + // Access イベント(ls による atime 更新など)は無視 + !matches!(debounced_event.kind, EventKind::Access(_)) + }); if should_rebuild { println!("[INFO] File changed, rebuilding..."); @@ -155,7 +167,6 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc>) -> Result<() // 現在のディレクトリ配下を再帰的に監視 debouncer - .watcher() .watch(¤t_dir, RecursiveMode::Recursive) .context("Failed to watch directory")?; From 256e00a1b1c4c7a4372b16bd88db81383060f97c Mon Sep 17 00:00:00 2001 From: zztkm <33755694+zztkm@users.noreply.github.com.> Date: Sat, 31 Jan 2026 02:38:20 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=88=E4=BF=AE=E6=AD=A3=E3=81=A8=E3=83=AC=E3=83=93?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E6=8C=87=E6=91=98=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - import の順序を cargo fmt に合わせる - paths 内のすべてのパスをチェックするように修正 Co-Authored-By: Claude Opus 4.5 --- src/subcommand_serve.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/subcommand_serve.rs b/src/subcommand_serve.rs index 675d82b..40fb286 100644 --- a/src/subcommand_serve.rs +++ b/src/subcommand_serve.rs @@ -7,7 +7,7 @@ use axum::{ response::Response, }; use notify::event::EventKind; -use notify_debouncer_full::{new_debouncer, notify::RecursiveMode, DebounceEventResult}; +use notify_debouncer_full::{DebounceEventResult, new_debouncer, notify::RecursiveMode}; use std::{ net::SocketAddr, path::{Path, PathBuf}, @@ -134,19 +134,13 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc>) -> Result<() None, move |res: DebounceEventResult| match res { Ok(events) => { - let should_rebuild = events.iter().any(|debounced_event| { - let path = match debounced_event.paths.first() { - Some(p) => p, - None => return false, - }; - - // dist ディレクトリ以下は無視 - if path.starts_with(&dist_path) { + let should_rebuild = events.iter().any(|event| { + // Access イベント(ls による atime 更新など)は無視 + if matches!(event.kind, EventKind::Access(_)) { return false; } - - // Access イベント(ls による atime 更新など)は無視 - !matches!(debounced_event.kind, EventKind::Access(_)) + // いずれかのパスが dist ディレクトリ外であれば再ビルド + event.paths.iter().any(|path| !path.starts_with(&dist_path)) }); if should_rebuild {