watchfiles
watchfiles copied to clipboard
Unreasonable return
Description
The target folder is D:\\work\\monitorTest
, there is a folder named D:\\work\\monitorTest\\newFolder
, when I delete it, I want to the output to be
{(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder')}, (<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder\\subFile1.xlsx')},(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx')}
.
When I undo the delete file operation , I want to the output to be {(<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder'),(<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder'\\subFile1.xlsx'), (<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx')
Example Code
from pathlib import Path
from watchfiles import Change, watch
def is_gdb(change: Change, path: str) -> bool:
if Path(path).parent.suffix == ".gdb":
return False
return True
for changes in watch(r"D:\work\monitorTest", watch_filter=is_gdb):
print(changes)
print()
Watchfiles Output
when I delete the folder:
print `{(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder')}`
whent I undo the delete folder operation:
print `{(<Change.modified: 2>, 'D:\\work\\monitorTest\\newFolder\\subFile1.xlsx'), (<Change.modified: 2>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx'), (<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder')}`
Operating System & Architecture
Windows-10-10.0.22631-SP0 10.0.22631
Environment
Windows11
Python & Watchfiles Version
python3.11 & watchfiles>=0.22.0
Rust & Cargo Version
No response