Skip to content

Commit 850833f

Browse files
authored
Remove filetime dependency (#690)
1 parent 65ea4b7 commit 850833f

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ flume = "0.11.1"
2525
deser-hjson = "2.2.4"
2626
env_logger = "0.11.2"
2727
file-id = { version = "0.2.2", path = "file-id" }
28-
filetime = "0.2.22"
2928
fsevent-sys = "4.0.0"
3029
futures = "0.3.30"
3130
inotify = { version = "0.11.0", default-features = false }

notify-debouncer-full/src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait FileIdCache {
4141

4242
/// A cache to hold the file system IDs of all watched files.
4343
///
44-
/// The file ID cache uses unique file IDs provided by the file system and is used to stich together
44+
/// The file ID cache uses unique file IDs provided by the file system and is used to stitch together
4545
/// rename events in case the notification back-end doesn't emit rename cookies.
4646
#[derive(Debug, Clone, Default)]
4747
pub struct FileIdMap {

notify/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ serialization-compat-6 = ["notify-types/serialization-compat-6"]
2828
notify-types.workspace = true
2929
crossbeam-channel = { workspace = true, optional = true }
3030
flume = { workspace = true, optional = true }
31-
filetime.workspace = true
3231
libc.workspace = true
3332
log.workspace = true
3433
walkdir.workspace = true

notify/src/poll.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ mod data {
6666
event::{CreateKind, DataChange, Event, EventKind, MetadataKind, ModifyKind, RemoveKind},
6767
EventHandler,
6868
};
69-
use filetime::FileTime;
7069
use std::{
7170
cell::RefCell,
7271
collections::{hash_map::RandomState, HashMap},
@@ -81,6 +80,13 @@ mod data {
8180

8281
use super::ScanEventHandler;
8382

83+
fn system_time_to_seconds(time: std::time::SystemTime) -> i64 {
84+
match time.duration_since(std::time::SystemTime::UNIX_EPOCH) {
85+
Ok(d) => d.as_secs() as i64,
86+
Err(e) => -(e.duration().as_secs() as i64),
87+
}
88+
}
89+
8490
/// Builder for [`WatchData`] & [`PathData`].
8591
pub(super) struct DataBuilder {
8692
emitter: EventEmitter,
@@ -356,7 +362,7 @@ mod data {
356362
let metadata = meta_path.metadata();
357363

358364
PathData {
359-
mtime: FileTime::from_last_modification_time(metadata).seconds(),
365+
mtime: metadata.modified().map_or(0, system_time_to_seconds),
360366
hash: data_builder
361367
.build_hasher
362368
.as_ref()

0 commit comments

Comments
 (0)