Skip to content

Commit

Permalink
move debouncer to own crate and fix audit failures
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpr03 committed Aug 2, 2022
1 parent 2e3a2ac commit 8a1d6e1
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 89 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ jobs:
if: matrix.version == '1.56.0' && matrix.os != 'macos-latest'
run: cargo check --features=serde

- name: check build example
- name: check build examples
if: matrix.version == 'stable'
run: cargo check -p watcher_kind
run: cargo check --package examples --examples

- name: test hot_reload_tide
if: matrix.version == 'stable'
run: cargo test -p hot_reload_tide
run: cargo test
working-directory: examples/hot_reload_tide

- name: test
if: matrix.version == 'stable'
Expand Down
75 changes: 10 additions & 65 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,69 +1,14 @@
[package]
name = "notify"
version = "5.0.0-pre.15"
rust-version = "1.56"
description = "Cross-platform filesystem notification library"
documentation = "https://docs.rs/notify"
homepage = "https://github.com/notify-rs/notify"
repository = "https://github.com/notify-rs/notify.git"
readme = "README.md"
license = "CC0-1.0 OR Artistic-2.0"
keywords = ["events", "filesystem", "notify", "watch"]
categories = ["filesystem"]
authors = [
"Félix Saparelli <me@passcod.name>",
"Daniel Faust <hessijames@gmail.com>"
]
[workspace]

edition = "2021"
exclude = [
"/clippy.toml",
".github/*"
members = [
"notify",
"notify-debouncer-mini",

# internal
"examples",
"examples/hot_reload_tide"
]

[dependencies]
bitflags = "1.0.4"
crossbeam-channel = "0.5.0"
filetime = "0.2.6"
libc = "0.2.4"
serde = { version = "1.0.89", features = ["derive"], optional = true }
walkdir = "2.0.1"

[target.'cfg(target_os="linux")'.dependencies]
inotify = { version = "0.9", default-features = false }
mio = { version = "0.8", features = ["os-ext"] }

[target.'cfg(target_os="macos")'.dependencies]
fsevent-sys = { version = "4", optional = true }
kqueue = { version = "1.0", optional = true }
mio = { version = "0.8", features = ["os-ext"], optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = ["fileapi", "handleapi", "ioapiset", "minwinbase", "synchapi", "winbase", "winnt"] }

[target.'cfg(any(target_os="freebsd", target_os="openbsd", target_os = "netbsd", target_os = "dragonflybsd"))'.dependencies]
kqueue = "^1.0.4" # fix for #344
mio = { version = "0.8", features = ["os-ext"] }

[dev-dependencies]
futures = "0.3"
serde_json = "1.0.39"
tempfile = "3.2.0"
nix = "0.23.1"

[features]
default = ["macos_fsevent"]
timing_tests = []
manual_tests = []
macos_kqueue = ["kqueue", "mio"]
macos_fsevent = ["fsevent-sys"]

[patch.crates-io]
notify = { path = "." }

[workspace]
members = [
".",
"examples/hot_reload_tide",
"examples/watcher_kind"
]
notify = { path = "notify/" }
notify-debouncer-mini = { path = "notify-debouncer-mini/" }
35 changes: 35 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "examples"
version = "0.0.0"
publish = false
edition = "2021"

[dev-dependencies]
notify = { version = "5.0.0-pre.15" }
notify-debouncer-mini = { version = "0.1" }
futures = "0.3"

[[example]]
name = "async_monitor"
path = "async_monitor.rs"

[[example]]
name = "monitor_raw"
path = "monitor_raw.rs"

[[example]]
name = "debounced"
path = "debounced.rs"

[[example]]
name = "poll_sysfs"
path = "poll_sysfs.rs"

[[example]]
name = "watcher_kind"
path = "watcher_kind.rs"

# specifically in its own sub folder
# to prevent audit from complaining
#[[example]]
#name = "hot_reload_tide"
3 changes: 2 additions & 1 deletion examples/debounced.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{path::Path, time::Duration};

use notify::{new_debouncer, RecursiveMode, Watcher};
use notify::{RecursiveMode, Watcher};
use notify_debouncer_mini::new_debouncer;

fn main() {
std::thread::spawn(|| {
Expand Down
2 changes: 1 addition & 1 deletion examples/hot_reload_tide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ tide = "0.16.0"
async-std = { version = "1.6.0", features = ["attributes"] }
serde_json = "1.0"
serde = "1.0.115"
notify = { version = "5.0.0-pre.15", features = ["serde"] }
notify = { version = "5.0.0-pre.15", features = ["serde"], path = "../../notify" }
2 changes: 1 addition & 1 deletion examples/hot_reload_tide/tests/messages_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hot_reload_tide::messages::{Config, load_config};
use hot_reload_tide::messages::{load_config, Config};

#[test]
fn load_config_from_file() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ fn main() {
} else {
Box::new(RecommendedWatcher::new(tx).unwrap())
};
// use _watcher here
}
10 changes: 0 additions & 10 deletions examples/watcher_kind/Cargo.toml

This file was deleted.

14 changes: 14 additions & 0 deletions notify-debouncer-mini/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "notify-debouncer-mini"
version = "0.1.0"
edition = "2021"
description = "notify mini debouncer for events"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
name = "notify_debouncer_mini"
path = "src/lib.rs"

[dependencies]
notify = "5.0.0-pre.15"
2 changes: 1 addition & 1 deletion src/debouncer.rs → notify-debouncer-mini/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
time::{Duration, Instant},
};

use crate::{Error, ErrorKind, Event, RecommendedWatcher, Watcher};
use notify::{Error, ErrorKind, Event, RecommendedWatcher, Watcher};

/// Deduplicate event data entry
struct EventData {
Expand Down
6 changes: 6 additions & 0 deletions notify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target
/Cargo.lock
.*.sw*
tests/last-fails
tests/last-run.log
.cargo
54 changes: 54 additions & 0 deletions notify/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[package]
name = "notify"
version = "5.0.0-pre.15"
rust-version = "1.56"
description = "Cross-platform filesystem notification library"
documentation = "https://docs.rs/notify"
homepage = "https://github.com/notify-rs/notify"
repository = "https://github.com/notify-rs/notify.git"
readme = "README.md"
license = "CC0-1.0 OR Artistic-2.0"
keywords = ["events", "filesystem", "notify", "watch"]
categories = ["filesystem"]
authors = [
"Félix Saparelli <me@passcod.name>",
"Daniel Faust <hessijames@gmail.com>"
]

edition = "2021"

[dependencies]
bitflags = "1.0.4"
crossbeam-channel = "0.5.0"
filetime = "0.2.6"
libc = "0.2.4"
serde = { version = "1.0.89", features = ["derive"], optional = true }
walkdir = "2.0.1"

[target.'cfg(target_os="linux")'.dependencies]
inotify = { version = "0.9", default-features = false }
mio = { version = "0.8", features = ["os-ext"] }

[target.'cfg(target_os="macos")'.dependencies]
fsevent-sys = { version = "4", optional = true }
kqueue = { version = "1.0", optional = true }
mio = { version = "0.8", features = ["os-ext"], optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = ["fileapi", "handleapi", "ioapiset", "minwinbase", "synchapi", "winbase", "winnt"] }

[target.'cfg(any(target_os="freebsd", target_os="openbsd", target_os = "netbsd", target_os = "dragonflybsd"))'.dependencies]
kqueue = "^1.0.4" # fix for #344
mio = { version = "0.8", features = ["os-ext"] }

[dev-dependencies]
serde_json = "1.0.39"
tempfile = "3.2.0"
nix = "0.23.1"

[features]
default = ["macos_fsevent"]
timing_tests = []
manual_tests = []
macos_kqueue = ["kqueue", "mio"]
macos_fsevent = ["fsevent-sys"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions src/lib.rs → notify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#![deny(missing_docs)]

pub use config::{Config, RecursiveMode};
pub use debouncer::new_debouncer;
pub use error::{Error, ErrorKind, Result};
pub use event::{Event, EventKind};
use std::path::Path;
Expand Down Expand Up @@ -143,7 +142,6 @@ pub mod null;
pub mod poll;

mod config;
mod debouncer;
mod error;

/// The set of requirements for watcher event handling functions.
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/poll.rs → notify/src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ impl PollWatcher {
{
data_builder.update_timestamp();


let vals = watches.values_mut();
for watch_data in vals {
watch_data.rescan(&mut data_builder);
Expand Down
File renamed without changes.
12 changes: 8 additions & 4 deletions release_checklist.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release checklist of files to update

- update changelog
- update readme
- update lib.rs
- update cargo.toml
Specifically the notify version.

- update CHANGELOG.md
- update README.md
- update notify/lib.rs
- update notify/cargo.toml examples/Cargo.toml examples/hot_reload_tide/Cargo.toml
- bump version number on the root Cargo.toml and examples
- maybe update notify-debouncer-mini/Cargo.toml

0 comments on commit 8a1d6e1

Please sign in to comment.