Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 35 additions & 102 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
17 changes: 11 additions & 6 deletions src/subcommand_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{DebounceEventResult, new_debouncer, notify::RecursiveMode};
use std::{
net::SocketAddr,
path::{Path, PathBuf},
Expand Down Expand Up @@ -130,12 +131,17 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc<Mutex<bool>>) -> 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(|event| {
// Access イベント(ls による atime 更新など)は無視
if matches!(event.kind, EventKind::Access(_)) {
return false;
}
// いずれかのパスが dist ディレクトリ外であれば再ビルド
event.paths.iter().any(|path| !path.starts_with(&dist_path))
});

if should_rebuild {
println!("[INFO] File changed, rebuilding...");
Expand All @@ -155,7 +161,6 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc<Mutex<bool>>) -> Result<()

// 現在のディレクトリ配下を再帰的に監視
debouncer
.watcher()
.watch(&current_dir, RecursiveMode::Recursive)
.context("Failed to watch directory")?;

Expand Down