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

silently fails if path is file #1034

Open
avelican opened this issue Feb 25, 2024 · 8 comments · May be fixed by #1054
Open

silently fails if path is file #1034

avelican opened this issue Feb 25, 2024 · 8 comments · May be fixed by #1054

Comments

@avelican
Copy link

Having written my code in a rush, I set the path to be a file rather than a directory.
The code runs without warnings or errors, but fails to report modifications to the file.
It seems watchdog supports only monitoring directories, not individual files.

I suggest watchdog should either:
A) support events on a single file (perhaps this can be done simply by monitoring its directory and ignoring changes on everything that isn't that file)
This solution seems more ergonomic from user POV.
Alternatively,
B) If given path is file, throw an exception and say it must be a directory

(Please forgive me if I've overlooked something, I haven't had time to take a proper look at how watchdog works yet.)

@BoboTiG
Copy link
Collaborator

BoboTiG commented Feb 26, 2024

What OS?

@LeStahL
Copy link

LeStahL commented Mar 19, 2024

I see this behavior on Windows 11 as well.

@prshir
Copy link

prshir commented Mar 31, 2024

Could you post your code to reproduce the silent fail?
I tried to reproduce specifying file rather than a directory and then changing it. Watchdog once printed Deleted directory: and my path to file. Not sure if it's a correct behavior but at least it doesn't fail. When I changed the file observed nothing happened.

TobiasRzepka added a commit to TobiasRzepka/watchdog that referenced this issue Jul 24, 2024
@handle1337
Copy link

handle1337 commented Jul 28, 2024

I tried to reproduce specifying a file rather than a directory and then change it. Watchdog once printed Deleted directory: and my path to file. Not sure if it's a correct behavior but at least it doesn't fail. When I changed the file observed nothing happened.

I was able to reproduce this with the same results on Windows 11, DirDeletedEvent(src_path='file_path\\somefile.txt', dest_path='', event_type='deleted', is_directory=True, is_synthetic=False), No events triggered after changing the target file.

I like the idea of supporting events on single files, is that something that would be in line with the project's goals?

update: clarification, in the test I am specifying a file, not dir

TobiasRzepka added a commit to TobiasRzepka/watchdog that referenced this issue Jul 28, 2024
@BoboTiG
Copy link
Collaborator

BoboTiG commented Jul 28, 2024

I like the idea of supporting events on single files, is that something that would be in line with the project's goals?

Yes! I see you already wrote some code :)
If you mind opening a PR, please add tests 🙏

@TobiasRzepka
Copy link

handle is someone else - we were just overlapped with the responses.
DirDeletedEvent is triggered because CreateFileW can only monitor directories. You told it to scan a directory but now it's a file! Therefore raise an DirDeletedEvent.
I will look for some tests...

@TobiasRzepka
Copy link

Need some more time because of vacation. Was still looking for some end to end test but didn't found anything. Am I right?

TobiasRzepka added a commit to TobiasRzepka/watchdog that referenced this issue Sep 17, 2024
@TobiasRzepka
Copy link

TobiasRzepka commented Sep 17, 2024

Testcases are now added. Let me know if it's okay. Run on Win 10 and Ubuntu 24.04 without problems.

TobiasRzepka added a commit to TobiasRzepka/watchdog that referenced this issue Oct 3, 2024
TobiasRzepka added a commit to TobiasRzepka/watchdog that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants