gow
gow copied to clipboard
Ignore directory prefixed with dot
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
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".
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...
@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?
@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
@mitranim please look at #23
Main reasons I used rjeczalik/notify and avoided fsnotify/fsnotify:
rjeczalik/notifysupports recursive watch out of the box.rjeczalik/notifyuses OS-specific FS notification APIs and avoids polling. It performs NO work when waiting for FS notifications. Meanwhilefsnotify/fsnotifyuses 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.
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
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.