diff --git a/ark-cli/Cargo.toml b/ark-cli/Cargo.toml index a60f5a1a..ea661d3d 100644 --- a/ark-cli/Cargo.toml +++ b/ark-cli/Cargo.toml @@ -26,7 +26,7 @@ lazy_static = "1.4.0" canonical-path = "2.0.2" -fs-index = { path = "../fs-index" } +fs-index = { path = "../fs-index", features = ["watch"] } fs-atomic-versions = { path = "../fs-atomic-versions" } fs-metadata = { path = "../fs-metadata" } fs-properties = { path = "../fs-properties" } diff --git a/fs-index/Cargo.toml b/fs-index/Cargo.toml index 1e1cea99..4057f8aa 100644 --- a/fs-index/Cargo.toml +++ b/fs-index/Cargo.toml @@ -15,11 +15,11 @@ anyhow = "1.0.58" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } # For the watch API -notify = "6.1" -notify-debouncer-full = "0.3" -futures = "0.3" -async-stream = "0.3" -tokio = { version = "1.40", features = ["full"] } +notify = { version = "6.1", optional = true } +notify-debouncer-full = { version = "0.3", optional = true } +futures = { version = "0.3", optional = true } +async-stream = { version = "0.3", optional = true } +tokio = { version = "1.40", features = ["full"], optional = true } fs-storage = { path = "../fs-storage" } @@ -27,6 +27,10 @@ fs-storage = { path = "../fs-storage" } data-error = { path = "../data-error" } data-resource = { path = "../data-resource" } + +[features] +watch = ["notify", "notify-debouncer-full", "futures", "async-stream", "tokio"] + [dev-dependencies] uuid = { version = "1.6.1", features = ["v4"] } # benchmarking diff --git a/fs-index/README.md b/fs-index/README.md index 6d4cd680..427db943 100644 --- a/fs-index/README.md +++ b/fs-index/README.md @@ -15,7 +15,7 @@ The most important struct in this crate is `ResourceIndex` which comes with: - `get_resource_by_path`: Query a resource from the index by its path. - **Selective API** - `update_one`: Method to manually update a specific resource by selectively rescanning a single file. -- **Watch API** +- **Watch API** (Enable with `watch` feature) - `watch`: Method to watch a directory for changes and update the index accordingly. > **Note:** To see the watch API in action, run the `index_watch` example or check `ark-cli watch` command. diff --git a/fs-index/src/lib.rs b/fs-index/src/lib.rs index 231c6f0c..ab86fe00 100644 --- a/fs-index/src/lib.rs +++ b/fs-index/src/lib.rs @@ -1,10 +1,12 @@ mod index; mod serde; mod utils; +#[cfg(feature = "watch")] mod watch; pub use index::{IndexUpdate, ResourceIndex}; pub use utils::load_or_build_index; +#[cfg(feature = "watch")] pub use watch::{watch_index, WatchEvent}; #[cfg(test)]