Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watching for file changes on complete file transfer

Tags:

node.js

fs

I have a simple node script that looks for a file changes and copies file to the remote server using ssh.

fs.watch(filename,function(curr,prev){

//copy file to the remote server

});

However, since the file i'm watching is uploaded via ftp and for every chunk of data i recieve the file gets changed and the callback gets fired. Is there any way to look for changes only when the complete file has been transfered?

Thanks in advance.

like image 279
I_Debug_Everything Avatar asked Nov 26 '25 12:11

I_Debug_Everything


1 Answers

I know this is an old question but for anyone else in the same situation there is now the below module:

https://www.npmjs.com/package/remote-file-watcher

like image 185
Jamie Deakin Avatar answered Nov 29 '25 02:11

Jamie Deakin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!