Fix watch.rs: import notify::Watcher trait, use tauri JoinHandle, drop unused imports
This commit is contained in:
parent
66e4de33b5
commit
ab75ca9bbb
1 changed files with 9 additions and 5 deletions
|
|
@ -4,26 +4,30 @@
|
||||||
//! ReadDirectoryChangesW on the WSL 9P mount (`\\wsl$\...`) is unreliable, so
|
//! ReadDirectoryChangesW on the WSL 9P mount (`\\wsl$\...`) is unreliable, so
|
||||||
//! a 60s tokio interval also runs `refresh_and_emit` to backstop missed events.
|
//! a 60s tokio interval also runs `refresh_and_emit` to backstop missed events.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use notify::{RecommendedWatcher, RecursiveMode};
|
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use notify_debouncer_full::{new_debouncer, DebounceEventResult, FileIdMap, Debouncer};
|
use notify_debouncer_full::{new_debouncer, DebounceEventResult, FileIdMap, Debouncer};
|
||||||
|
use tauri::async_runtime::JoinHandle;
|
||||||
use tauri::{AppHandle, Emitter, Manager};
|
use tauri::{AppHandle, Emitter, Manager};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::jsonl::{enumerate_jsonl, parse_jsonl_from, stat as file_stat, UsageEvent};
|
use crate::jsonl::{enumerate_jsonl, parse_jsonl_from, stat as file_stat, UsageEvent};
|
||||||
use crate::paths::resolve_roots;
|
use crate::paths::resolve_roots;
|
||||||
use crate::state::{AppState, FileCache, SharedState};
|
use crate::state::{FileCache, SharedState};
|
||||||
use crate::usage::build_snapshot;
|
use crate::usage::build_snapshot;
|
||||||
|
|
||||||
/// Lives for the lifetime of the app (held by AppState). Drop unregisters.
|
/// Lives for the lifetime of the app (held by AppState). Drop unregisters.
|
||||||
|
///
|
||||||
|
/// Note: tasks are spawned via `tauri::async_runtime::spawn`, which returns
|
||||||
|
/// `tauri::async_runtime::JoinHandle` — distinct from `tokio::task::JoinHandle`
|
||||||
|
/// even though we use tokio primitives (`time::interval`, `sync::mpsc`) inside.
|
||||||
pub struct WatcherHandle {
|
pub struct WatcherHandle {
|
||||||
_debouncer: Debouncer<RecommendedWatcher, FileIdMap>,
|
_debouncer: Debouncer<RecommendedWatcher, FileIdMap>,
|
||||||
_poll_task: tokio::task::JoinHandle<()>,
|
_poll_task: JoinHandle<()>,
|
||||||
_consumer_task: tokio::task::JoinHandle<()>,
|
_consumer_task: JoinHandle<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(app: AppHandle, state: SharedState) -> anyhow::Result<WatcherHandle> {
|
pub fn start(app: AppHandle, state: SharedState) -> anyhow::Result<WatcherHandle> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue