Skip to content

Io error instead of PathNotFound returned, when recursivemode is NonRecursive #685

@JanzenJohn

Description

@JanzenJohn

I'm on 8.0.0 and when Watching a non existent file I get a an Io::Error with ErrorKind::NotFound, this is after the merge of #611

complete code

#[tokio::main]
async fn main() {
    let mut config_file_events = match watching::async_watcher("/etc/configfile").await {
        Ok(v) => v,
        Err(e) => match e.kind {
            notify::ErrorKind::PathNotFound => todo!("setup: correct error"),
            notify::ErrorKind::Io(e) if e.kind() == std::io::ErrorKind::NotFound => {
                todo!("setup: wrong error")
            }
            _ => todo!("setup: some other error"),
        },
    };

    while let Some(config_file_event) = config_file_events.recv().await {
        match config_file_event {
            Ok(_) => todo!("running: success"),
            Err(x) => match x.kind {
                _ => todo!("running: error"),
            },
        }
    }
}

async fn async_watcher<T: AsRef<Path>>(
    path: T,
) -> notify::Result<mpsc::Receiver<notify::Result<Event>>> {
    let (tx, rx) = mpsc::channel(1);
    let mut watcher = INotifyWatcher::new(
        move |res| futures::executor::block_on(async { tx.send(res).await.unwrap() }),
        Config::default(),
    )?;
    watcher.watch(path.as_ref(), notify::RecursiveMode::NonRecursive)?;

    Ok(rx)
}

this results in the output of

not yet implemented: setup: wrong error

This only happens when i choose NonRecursive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions