notify icon indicating copy to clipboard operation
notify copied to clipboard

Add a Note to README When use posix path on Windows

Open WingDust opened this issue 4 years ago • 6 comments

System details

  • OS/Platform name and version: Windows 10
  • Rust version (if building from source): rustc --version:rustc 1.54.0 (a178d0322 2021-07-26)
  • Notify version (or commit hash if building from git): 5.0.0-pre.13 and 4. 0.17
  • If you're coming from a project that makes use of Notify, what it is, and a link to the downstream issue if there is one:
  • Filesystem type and options:
  • On Linux: Kernel version:
  • On Windows: version and if you're running under Windows, Cygwin (unsupported), Linux Subsystem:
  • If you're running as a privileged user (root, System):
  • If you're running in a container, details on the runtime and overlay:
  • If you're running in a VM, details on the hypervisor:

What you did (as detailed as you can)

When i use notify watch directory on Windows, the path is posix style like "G:/Feature/" Return Event 's path will like "G:/Feature/\\22.mp4"

this is what i test on 5.0.0-pre.13

        use std::path::Path;
         let (tx, rx) = std::sync::mpsc::channel();

        // Automatically select the best implementation for your platform.
        // You can also access each implementation directly e.g. INotifyWatcher.
        let mut watcher = RecommendedWatcher::new(tx).unwrap();

        // let mut watcher = recommended_watcher(|res| {
        //     match res {
        //     Ok(event) => println!("event: {:?}", event),
        //     Err(e) => println!("watch error: {:?}", e),
        //     }
        // }).unwrap();
        watcher.watch(Path::new("G:/Feature film/"), RecursiveMode::Recursive).unwrap();

        for res in rx {
        match res {
            Ok(event) => println!("changed: {:?}", event),
            Err(e) => println!("watch error: {:?}", e),
        }
    }

a remove event will print

changed: Event { kind: Remove(Any), paths: ["G:/Feature/\\22.mp4"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }

because posix path also work with notify on Windows,but OsString::from_wide(encoded_path) will return windows style path like Feature\\22.mp4

4.0.17 is same .

So Should add a Note to README When use posix path on Windows.

What you expected

What happened

WingDust avatar Dec 21 '21 09:12 WingDust

I'm not entirely sure what you want to have on the readme. But I think I've seen a similar issue with windows when using posix-path libs on windows recently.

0xpr03 avatar Dec 21 '21 09:12 0xpr03

@0xpr03 if don't have note on readme , new beginner will fill this trap again

WingDust avatar Dec 21 '21 14:12 WingDust

I think it's more of a behavior issue rather than a document's one, we could (even should?) normalize a path. By the way, such documentation should go to a doc comment, not README IMO.

JohnTitor avatar Dec 21 '21 18:12 JohnTitor

@JohnTitor I'd leave that to you if you already know how you want to proceed.

0xpr03 avatar Dec 22 '21 13:12 0xpr03

So, the current behavior works correctly if a user specifies a Windows-like path (e.g. G:\Feature\ -> G:\Feature\22.mp4), right? Then, what we could do is to check if a user specifies a posix-like path then normalize a joined path to a posix-like one (another option would be normalizing a user specified path to a Windows-like and it's easier, but it'd be confusing IMO). I'm, however, afraid that I cannot take a closer look at that in the near future (I'm inactive on FLOSS these days), so I can only put down my thoughts here for now.

JohnTitor avatar Dec 23 '21 07:12 JohnTitor

+1

refaelsh avatar Jan 21 '22 13:01 refaelsh