Closed Alexinio97 closed 1 year ago
and I was wondering if I want to listen for multiple requests do I need to create a thread for each one?
Right now the code for FileSystemWatcher actually creates a thread and runs it for you for every change notify request made https://github.com/jborean93/smbprotocol/blob/master/src/smbprotocol/change_notify.py#L298. It's not very efficient but it's currently how it is implemented. Unfortuantely there is no callback mechanism right now to allow you to run something when an event is fired but there is a very rudimentary event on the object you might be able to take advantage off.
The only way to lock a file is to open a read/write handle to it right?
For Windows pretty much, if you open a file without providing the FileShare
access then nothing else should be able to open their own handle to that file. There are also the concept of OpLocks in SMB which I haven't really played with too much but from what I understand they are more a way to be notified if someone else opens a handle to the same file rather than an actual lock.
Thanks a lot for your answer! Regarding the file system watcher, I experienced some differences between a linux share and a windows one. Some files are not captured by the watcher on linux when I try to copy a batch of them into my windows share. I guess this is because of the windows OS right?
Regarding my last question, I saw the example you gave here https://github.com/jborean93/smbprotocol/issues/172. The foreach was missing from my implementation, now every changed folder/file gets printed. Thank you! I'll close this.
Hello, I have two questions related to FileSystemWatcher and file locking.
Thank you!