Skip to content

Commit

Permalink
Remove track file ids option from fs watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaust committed Jan 16, 2024
1 parent 3c1cb36 commit 4e278d3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
6 changes: 0 additions & 6 deletions examples/api/src/views/FileSystem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
let watchPath = "";
let watchDebounceDelay = 0;
let watchRecursive = false;
let watchTrackFileIds = false;
let unwatchFn;
let unwatchPath = "";
Expand Down Expand Up @@ -155,7 +154,6 @@
let options = {
recursive: watchRecursive,
delayMs: parseInt(watchDebounceDelay),
trackFileIds: watchTrackFileIds,
};
if (options.delayMs === 0) {
fs.watchImmediate(watchPath, onMessage, options)
Expand Down Expand Up @@ -239,10 +237,6 @@
<input type="checkbox" id="watch-recursive" bind:checked={watchRecursive} />
<label for="watch-recursive">Recursive</label>
</div>
<div>
<input type="checkbox" id="watch-track-file-ids" bind:checked={watchTrackFileIds} />
<label for="watch-track-file-ids">Track file IDs (requires a debounce delay to be set)</label>
</div>
<br />
<div>
<button class="btn" on:click={watch}>Watch</button>
Expand Down
2 changes: 0 additions & 2 deletions plugins/fs/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,6 @@ interface WatchOptions {
interface DebouncedWatchOptions extends WatchOptions {
/** Debounce delay */
delayMs?: number;
/** Keep track of the file system IDs of all files */
trackFileIds?: boolean;
}

/**
Expand Down
10 changes: 1 addition & 9 deletions plugins/fs/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
// SPDX-License-Identifier: MIT

use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
use notify_debouncer_full::{
new_debouncer, DebounceEventResult, Debouncer, FileIdCache, FileIdMap,
};
use notify_debouncer_full::{new_debouncer, DebounceEventResult, Debouncer, FileIdMap};
use serde::Deserialize;
use tauri::{
ipc::Channel,
Expand Down Expand Up @@ -77,8 +75,6 @@ pub struct WatchOptions {
dir: Option<BaseDirectory>,
recursive: bool,
delay_ms: Option<u64>,
#[serde(default)]
track_file_ids: bool,
}

#[tauri::command]
Expand All @@ -104,9 +100,6 @@ pub async fn watch<R: Runtime>(
let mut debouncer = new_debouncer(Duration::from_millis(delay), None, tx)?;
for path in &resolved_paths {
debouncer.watcher().watch(path.as_ref(), mode)?;
if options.track_file_ids {
debouncer.cache().add_path(path.as_ref());
}
}
watch_debounced(on_event, rx);
WatcherKind::Debouncer(debouncer)
Expand Down Expand Up @@ -137,7 +130,6 @@ pub async fn unwatch<R: Runtime>(app: AppHandle<R>, rid: ResourceId) -> CommandR
debouncer.watcher().unwatch(path.as_ref()).map_err(|e| {
format!("failed to unwatch path: {} with error: {e}", path.display())
})?;
debouncer.cache().remove_path(path.as_ref());
}
}
WatcherKind::Watcher(ref mut w) => {
Expand Down

0 comments on commit 4e278d3

Please sign in to comment.