diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 9af3699de0..74aa334e2b 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -2007,9 +2007,23 @@ declare namespace Deno { */ export function resources(): ResourceMap; + /** + * Additional information for FsEvent objects with the "other" kind. + * + * - "rescan": rescan notices indicate either a lapse in the events or a + * change in the filesystem such that events received so far can no longer + * be relied on to represent the state of the filesystem now. An + * application that simply reacts to file changes may not care about this. + * An application that keeps an in-memory representation of the filesystem + * will need to care, and will need to refresh that representation directly + * from the filesystem. + */ + export type FsEventFlag = "rescan"; + export interface FsEvent { - kind: "any" | "access" | "create" | "modify" | "remove"; + kind: "any" | "access" | "create" | "modify" | "remove" | "other"; paths: string[]; + flag?: FsEventFlag; } /** diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs index 30c6d3aaa7..26ad255fd6 100644 --- a/runtime/ops/fs_events.rs +++ b/runtime/ops/fs_events.rs @@ -65,8 +65,9 @@ impl Resource for FsEventsResource { /// the complexity. #[derive(Serialize, Debug)] struct FsEvent { - kind: String, + kind: &'static str, paths: Vec, + flag: Option<&'static str>, } impl From for FsEvent { @@ -77,12 +78,15 @@ impl From for FsEvent { EventKind::Create(_) => "create", EventKind::Modify(_) => "modify", EventKind::Remove(_) => "remove", - EventKind::Other => todo!(), // What's this for? Leaving it out for now. - } - .to_string(); + EventKind::Other => "other", + }; + let flag = e.flag().map(|f| match f { + notify::event::Flag::Rescan => "rescan", + }); FsEvent { kind, paths: e.paths, + flag, } } }