Giter Club home page Giter Club logo

inotify-win's People

Contributors

aldecar avatar ashi009 avatar creallfluharty avatar lehnerpat avatar lhcgreg avatar petermosmans avatar thekid avatar yeerkkiller1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inotify-win's Issues

When multiple rapid changes happen to a monitored directory, only some are reported

An easy way to reproduce this is with Visual Studio. When you save a file in Visual Studio, it actually creates a temporary file and then replaces the main file with the temporary file. There are several steps in that process. If you watch a directory and save a file with Visual Studio, only some of the steps will be reported and it will be inconsistent which will be reported. For example, here's what was reported the first time I saved a particular file:

CREATE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\1pufrzgv.y11~

And here's what was reported the second time:

CREATE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\0oo5h2cc.aff~
CREATE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtml~RF863f7e1.TMP
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home

I took a look at the code and this is caused by using code like this:

                while (true)
                {
                    var e = w.WaitForChanged(changes);
                    /// Process...
                }

WaitForChanged synchronously waits for changes in the directory of the type specified in changes. If changes in the directory happen when processing a change notification, those changes are are not queued up anywhere and are lost.

The fix is to instead use the Created, Changed, Deleted, and Renamed events of the FileSystemWatcher. The delegate specified will be called asynchrously when a change in the directory occurs.

I'll be sending a pull request shortly that makes this change. Saving that same file in Visual Studio with this code results in the following being reported, much more than got reported before:

CREATE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\ayjxpflb.rqc~
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home
MODIFY C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\ayjxpflb.rqc~
CREATE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtmlRF864a436.TMP
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home
DELETE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtml
MODIFY C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtml
RF864a436.TMP
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home
MOVED_FROM C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\ayjxpflb.rqc~
MOVED_TO C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtml
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home
DELETE C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home\Home.cshtml~RF864a436.TMP
MODIFY,ISDIR C:\Users\Greg\Documents\Programming\animerecs-git\AnimeRecs.Web\Modules\Home

Set up automated build process and publish releases

Add GitHub pipelines to do create .exe files and publish them for download under "Releases" as soon as a tag of the form v*.*.* is pushed.

https://github.com/marketplace/actions/gh-release looks like a good fit, an alternative would be to simply use the gh tool directly using YAML:

run: |
  gh release create ${{ env.VERSION }} -n "${{ env.MESSAGE }}" -t "${{ env.NAME }}" ${{ env.FILES }}
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  VERSION: "tag for release"
  MESSAGE: "message for release"
  NAME: "release name"
  FILES: path/to/file1 path/to/file2 ...

(Source: softprops/action-gh-release#107 (comment))

path error on make

Not entirely sure the cause, didn't dig at all, but figured I would share my issue.

bash-4.1$ make
/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5/csc /nologo /target:exe /out:inotifywait.exe src\main\csharp_.cs
error CS2001: Source file 'srcmaincsharp_.cs' could not be found
fatal error CS2008: No inputs specified
make: *** [inotifywait.exe] Error 1

cant we capture open event of a file

Hi, like inotify tools in linux cant we capture open event of a file from listening folder using this. if not ,is there any alternative to achieve this

provide binary or build instructions

Hi,
I don't have the build environment for c or c#, I think many other people are the same, could you provide a binary download link? I would be nice if you can add the build requirements in the readme.

Thanks!

--exclude option and executable?

Hi,

First of all: This seems like a great idea. If it does what it promises, it is great!
However, I have some requests:

  1. Can you provide an inotify-win.exe executable for win32?
  2. Can you implement the --exclude option (i'd like to exclude some hidden directories from watching).

Thanks!

Spaces in the path

The command line argument "path" can't include spaces and ".
I shoud write
C:\progra~1
instead of
"C:\Program Files"

Cut/Move Operations incomplete

While within a folder being watched inotifywait.exe C:\Sync
if I move/cut a file test.txt within folders of C:\Sync\folder1 say to C:\Sync\folder2

inotify will report
C:\Sync\ DELETE C:\Sync\folder1\test.txt

But not report the accompanying paste I expect :
C:\Sync\ CREATE C:\Sync\folder2\test.txt

It works perfectly well for files moved between of in/out of a Watched DIR but not inside one.

Windows 7 .net3.5 compiler
Any Ideas ?

`inotifywait.exe` fails silently when STDIN is `NUL`

When supplying NUL as STDIN to inotifywait.exe the program seems to crash without writing anything to STDERR or returning a non-zero exit code. This happens when running inotifywait.exe as a windowless subprocess (my use case) or in a service, as well as using redirection in the shell, like so:

C:\path\to\inotify>inotifywait.exe . < NUL

C:\path\to\inotify>echo %ERRORLEVEL%
0

PS: Thanks for maintaining this! It has been very useful so far!

Edit: Perhaps this is intentional?

enquoted filenames are not supported

C:\temp>inotifywait.exe -m "C:\temp\1\"

Unhandled Exception: System.ArgumentException: Path does not exist: `C:\temp\1"`
   at De.Thekid.INotify.ArgumentParser.ParseArgument(String option, String[] args, Int32& i, Arguments result)
   at De.Thekid.INotify.ArgumentParser.Parse(String[] args)
   at De.Thekid.INotify.Runner.Main(String[] args)

and that, of course, means that one cannot watch files with spaces in names. Also if the file being watched is a directory there is no trailing [back]slash after its name like in linux inotifywait, so once this bug is fixed it won't be possible to determine whether the space is part of the name or a separator.

inotify-win doesn't stop after being executed without -m

I don't know if it is a featuer or a bug ๐Ÿ˜„ , but I have the following situation.
I run inotify-wait without the -m parameter and when i change a file, inotify-win captures the event successfully, but then, instead of exiting, it continues execution but fails to capture any more events.
Is this ok, or is something wrong?

Console output formatted differently and regex matched differently from (Linux) inotifywait

We use inotifywait in our little utility script gitwatch, and with the help of a user -- and inotify-win! -- we're now expanding our target platforms to Windows.

In this context I've run into the following two issues:

  • the console output of inotify-win is formatted differently from the Linux variant
  • related to this, inotify-win uses a different part of the event-generating file's path to match against the exclusion regexp.

I can provide analogous examples from both platforms to show the exact differences I've observed.

But first I wanted to ask if you are at all interested in improving the compatibility of this port. I think it would benefit users in general, because scripts building on top of inotifywait will be more easily portable to Windows with inotify-win, but there might be some cases where existing users of inotify-win would have to change their scripts.

I'm no C# wizard but I'd also be willing to help with a PR to get this rolling if you think it's worthwile.

Quoted paths

  1. inotifywait C:\
    ===> Watching C:\*.* for create, modify, delete, move

  2. inotifywait "C:\"
    Black screen, no output, hangs

  3. inotifywait C:\Test
    ===> Watching C:\Test*.* for create, modify, delete, move
    (works fine, cosmetic - no backslash delimiting path from wildcard)

  4. inotifywait "C:\Test"
    all OK like in 3)

  5. inotifywait "C:\Test\"
    like in 2) not working

  6. inotifywait "C:\Test\."
    all OK like in 3) and 4)

Results like 2) and 5) we can get if pass any not existing path. And even if we create this path later program still hangs.

Wrong Result

inotifywait -e create,delete,modify,move -mrq C:\Test

When moving C:\Test\TestFolder1\testfile.txt to C:\Test\TestFolder2
It results in c:\Test DELETE TestFolder1\testfile.txt which is wrong,
should be

c:\Test MOVED_FROM TestFolder1\testfile.txt
c:\Test MOVED_TO TestFolder2\testfile.txt

Fix for unhandled exception when using --exclude option

Hi:

I find the inotifywait.exe program very useful. However, I started to encounter problems when I started to use the "--exclude" option. By looking at Runner.cs, it looks to me that a "ReleaseMutex()" is missing. Here is (below) the change I made to the source code to solve my problem. This could be useful to others.

Thanks again,
TheGleM

From Runner.cs (original code):
if (null != _args.Exclude && _args.Exclude.IsMatch(e.Name))
{
continue;
}

From Runner.cs (modified code):
if (null != _args.Exclude && _args.Exclude.IsMatch(e.Name))
{
_mutex.ReleaseMutex();
continue;
}

Do you have a working Windows batch example?

Hi!

Just recently found your port and would love to try it under Windows! But I seem to be unable to get something working like

"inotifywait -m -e -create d:/examplefolder | windows_batch_to_do_something.cmd"

It is not about inotify not working correctly but more about how to use it in a concrete situation. I am unable to use Cygwin on the Windows machine, so I am stuck with win cmd...

Perhaps you already used it in such a way and have a small example :-) - if not, nevertheless, keep up the good work!

Regards
Holger

[Resource] Comparison of output and regexp behavior: inotifywait vs inotify-win

I've collected the output of both inotifywait and inotify-win for several test cases. The purpose of this is to show and compare the differences between the console output and the regexp behavior (these two are somewhat related) of the two variants.

Versions used when creating this comparison:

  • inotifywait from inotify-tools version 3.14-1ubuntu1 (Ubuntu 14.04 stable repo)
  • inotify-win current revision ( 6c0afa9 )

Plain-text versions of this comparison can be found in this gist.

As both the files in the gist and the comments in this thread will be sequential, I have also created a plain-text side-by-side; it is included in the gist linked above, but best viewed in raw format.

Note: This is meant to be used as a resource/reference, so the comparison doesn't get buried in a thread with lots of discussion. I recommend using other issue/PR threads to discuss this, and only referencing this issue and the files in the gist. (@thekid, feel free to rename the issue if you have a better title :D)

Compiled version?

Hi,

Is it possible to upload a compiled version to the repository?

It would be a great help and I don't have the environment required to compile it... :-(

Thanks in advance,

Mark

--include regex option

In Linux version since 3.20.1. Can be added to windows ver?

P.S.: And --includei too...

inotifywait in background hang terminal

When inotifywait is run un background the cygwin terminal hang

For exemple: inotifywait -m d: &

After it was impossible to use the terminal until inotifywait was killed

Possibly wrong default filter

When creating a watcher

new FileSystemWatcher {
    Path = path,
    IncludeSubdirectories = _recursive,
    Filter = "*.*"
})

the filter supposes there's a dot in file name, but there could be no dot.

Only last -e option takes effect

The Linux version of inotifywait supports multiple instances of the -e option, to listen for multiple event types. This version only seems to look at the last option. For example:

$ inotifywait -e modify -e move -e create -e delete -e attrib -r .
===> Watching for 0 in C:\example -r for attrib

$ inotifywait -e modify -e move -e create -e delete -r .
===> Watching for Deleted in C:\example -r for delete

$ inotifywait -e modify -e move -e create  -r .
===> Watching for Created in C:\example -r for create

$ inotifywait -e modify -e move  -r .
===> Watching for Renamed in C:\example -r for move

Also the "Watching for" messages seem to repeat themselves somewhat, like "Watching for Created in C:\example -r for create".

Except for this odd message: "Watching for 0 in C:\example -r for attrib". I presume it is different because attrib is not supported on Windows.

Can it trigger a script?

Hi, very interesting - but what can it actually do? Can I trigger a script with this? How to use this, e.g. to monitor a directory and copy a file if changed inside it? Thanks!

inotifywait.exe doing nothing

Hello,

I just cloned it and make it. Result was inotifywait. After making i moved it to /bin/ (cygwin)
I tried several versions of execution - for any reason it is doing absolutely nothing.
Any ideas?

thank you,
regards

Events on local mount detected, but not from original OS (using SAMBA, in Cygwin)

My setup is that I'm using Cygwin.

I have a samba share set up, and I'm using inotifywait.exe to monitor file changes in a directory. When I make the changes locally, they are noticed. But when the changes occur from the machine that the share lives on, they aren't.

Here's what I'm using:
inotifywait -r -m -e modify Y:/location/to/share | while read line ; do echo "Notified!" ; done &

Again, this works as expected when I modify files on my machine, but when they are logged to on the host, I'm not notified.

This could be a user error, too, As I'm also having issues watching specific files (it works with directories, but not individuals files), and using the cygwin-esque way of describing files (/cygdrive/y/location/to/share).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.