C
C#2y ago
GNUGradyn

✅ Does `FileSystemWatcher` work on linux? (Trying to monitor for files being added or renamed)

Hi. Im trying to monitor a directory for any files being added to it or renamed. I found FileSystemWatcher but the platform support is unclear. I suspect it does not work on linux because many of the events don't make sense on linux (e.g. how would LastWrite work when files arent locked on linux) Does this work on linux? if not what should I use instead?
19 Replies
Angius
Angius2y ago
$tias I guess?
Angius
Angius2y ago
The docs don't mention anything about it not working on Linux for what it's worth
333fred
333fred2y ago
It works
GNUGradyn
GNUGradynOP2y ago
just didnt want to write a bunch of code to handle the file and have it work on my windows laptop, only to deploy it to my server and find out it doesnt actually work lol just works? does it just not fire LastWrite then?
333fred
333fred2y ago
Though many linux systems have a lower number of inotify instances What do you think LastWrite means?
GNUGradyn
GNUGradynOP2y ago
I assumed it fired when the file was unlocked
333fred
333fred2y ago
No It fires when the last written time changes When that happens is OS-dependent
GNUGradyn
GNUGradynOP2y ago
ohhhhh an article i was reading suggesting watching for LastWrite to avoid picking up files that arent done being written to yet
333fred
333fred2y ago
It doesn't mean "the last write has occurred", if that's what you were thinking 🙂 I mean, that might certainly work
GNUGradyn
GNUGradynOP2y ago
yeah, the article suggested using it as such so i assumed it meant "the last write has occured" maybe ill just handle this firefox style and add .part to files until they're done being written and it can just ignore any .part files
333fred
333fred2y ago
But more because that's when the OS considers the file content to have been flushed to disk Both firefox and chrome do that
GNUGradyn
GNUGradynOP2y ago
then I don't have to worry about nuances in when the OS considers it "done" and such
333fred
333fred2y ago
Though chrome uses a different ext
GNUGradyn
GNUGradynOP2y ago
ah interesting, i dont use chrome much lol thank you
333fred
333fred2y ago
yw
GNUGradyn
GNUGradynOP2y ago
this was very helpful i appreciate it
333fred
333fred2y ago
Don't forget to $close if there are no more questions
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server