Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore directory prefixed with dot #17

Open
Altiano opened this issue Apr 23, 2021 · 8 comments
Open

Ignore directory prefixed with dot #17

Altiano opened this issue Apr 23, 2021 · 8 comments

Comments

@Altiano
Copy link

Altiano commented Apr 23, 2021

When running go test ./...

Directories prefiexed with dot :

.mongo-data

in my case, is ignored by go

Using gow test ./...
seems to reading that directory,

The problem is, that that directory is bound to container, thus resulting in this error:

.mongo-data/journal: permission denied
@mitranim
Copy link
Owner

mitranim commented Apr 24, 2021

gow watches everything in the CWD, passing ./... to the watcher. You can use -i to ignore specific paths:

gow -i .mongo-data <...>

Though I'm confused about the meaning of "directories prefixed with dot are ignored by go".

@mitranim
Copy link
Owner

Hmm on second thought, -i probably wouldn't work in this case. The watcher will still try to access the directory. gow's filter applies only to the already-received filesystem events. Your case needs a different solution...

@vanodevium
Copy link
Contributor

@mitranim I faced the same problem

Real case: in my root folder there is a data folder which is a volume for docker containers. So "permission denied" from watcher...

I looked at the source code of rjeczalik/notify, there is no way to get around errors of this kind. Some person tried to fix it (add the ability to skip folders), but this code was not accepted.

Conclusion: can we make it so that the recursive pass through the file system is on the gow side, and the necessary folders are already passed as arguments to the watcher?

@vanodevium
Copy link
Contributor

@mitranim

Learned more.

Even the ignore list on our part will not help, since the rjeczalik/notify automatically scan all nested folders recursively.

I looked at how other tools get around this problem - they all switched to fsnotify/fsnotify

@vanodevium
Copy link
Contributor

@mitranim please look at #23

@mitranim
Copy link
Owner

mitranim commented May 13, 2022

Main reasons I used rjeczalik/notify and avoided fsnotify/fsnotify:

  • rjeczalik/notify supports recursive watch out of the box.
  • rjeczalik/notify uses OS-specific FS notification APIs and avoids polling. It performs NO work when waiting for FS notifications. Meanwhile fsnotify/fsnotify uses polling and CONSTANTLY performs work even when nothing is happening, contributing to battery drain.

If possible, I'd prefer a solution that doesn't involve switching to a polling-based library.

@vanodevium
Copy link
Contributor

Yes, I see.

rjeczalik/notify supports recursive watch out of the box.

This is exactly the main problem: it tries to read folders that are not accessible.
It would not be scary if it threw an error, but it still initialized the watcher.
But it just throws an error and nothing can be done about it, since it simply cannot ignore files.

So with rjeczalik/notify we won't be able to bypass the permissions issue...

Anyway, thank you for your attention to this problem. Ping me if you have any advice or questions

@mitranim
Copy link
Owner

Before doing any reworks, it would be nice if I could debug this locally. There might be simpler solutions. I tried to reproduce this by altering directory permissions, but wasn't successful. If anyone still has this problem, please suggest how to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants