在完成文件传输时监视文件更改 [英] Watching for file changes on complete file transfer
本文介绍了在完成文件传输时监视文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的节点脚本,用于查找文件更改并使用ssh将文件复制到远程服务器.
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
});
但是,由于我正在观看的文件是通过ftp
上传的,因此对于我收到的每一个数据块,文件都会被更改,并且回调函数也会被触发.仅在传输完整文件后,有什么方法可以寻找更改吗?
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?
谢谢.
推荐答案
我知道这是一个老问题,但对于其他处于相同情况的人,现在有以下模块:
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
这篇关于在完成文件传输时监视文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文