#Watch for changes to txt file
6 messages · Page 1 of 1 (latest)
Ideally using JS. I don't see anything in the fs doc for watch or anything like that.
Not a solution but I remember a while back I had to do something similar with js and I asked on some forums and basically there are two approaches, you can either checksum the file and compare it and do that on a loop (with some timeout) believe it or not it's actually used as bad as it sounds
The better approach is to use a native system module to do that, this differs from os to os and you'll need to implement it for each os you're supporting, I am not even sure it's supported everywhere but iirc I was on windows at the tome and it was possible I don't remember how though
Yeah, I'm being pretty janky right now. I'm just checking it every second. But, I'm hoping to to find a better way. I really only need to target Windows in this case.
You could either check every N milliseconds if the file has changed by checking if its metadata has changed since last time it scanned it
Or you can set up watching with Rust
you could use the fs-watch plugin to listen for file changes without having to constantly check it yourself https://github.com/tauri-apps/plugins-workspace/tree/dev/plugins/fs-watch