4 ms·
Don't change-notification-based mechanisms suffer from potentially reading a half-written file? Or do you do something more clever?
by dataflow 7mo ago
Don't change-notification-based mechanisms suffer from potentially reading a half-written file? Or do you do something more clever?
- cyrusradfar 7mo agoThere's a 3-second debounce. Don't hold me to that timeframe, that's the default now. It doesn't read the file the instant the OS fires the event. It accumulates events and waits for 3 seconds of silence before reading. So if an editor does write-tmp → rename (atomic save), or a tool writes in chunks, we only read after the dust settles. I accept there are cases if the editor crashes mid-state that you have a corrupted state but there was never a good state to save, so, arguably you'd just restore to what's on file and remove the corrupt partial write. It's not bulletproof against a program that holds a file open and writes to it continuously for more than 3 seconds, but in practice that doesn't happen with text files by Agent tools or IDEs. Feel free to follow up for clarity.
- dataflow 7mo agoThanks, that makes sense.