I’m trying to create a script to transfer files to my NAS for backup purposes.
I’m using the SSH2 module ( https://github.com/mscdex/ssh2
) to set up a SFTP connection.
For smaller files all goes well, with larger files (>500MB) it often just freezes somewhere between 70% and 100% completion.
The fastPut method, which i use for the transfers, suddenly just stops transfering, doesn’t trigger any events anymore.
I’ve taken out the relevant piece of code:
var uploadUpdate=true; sftp.fastPut(localPath+'/'+upload, receiver.path+'/'+newDir+'/'+upload, {step:function(totalTransferred, chunk, total){ if(uploadUpdate){ //since this event will be triggered a lot I figured I should keep some time (5 sec) between the logs uploadUpdate=false; console.log("- Progress '"+upload+"' => "+(Math.floor(totalTransferred/total*10000)/100)+"%, "+totalTransferred+" of "+total+" bytes, chunk: "+chunk); setTimeout(function(){ uploadUpdate=true; },5000); } }}, function(err){ if(err){ if(!fileErrors[upload]) fileErrors[upload]=0; ++fileErrors[upload]; if(fileErrors[upload]==5) console.log("'"+upload+"' failed 5 times... skipping now..."); else{ console.log("Upload of '"+upload+"' failed, re-add to queue."); uploadsToDo.push(upload); } } nextUpload(); });
Does anyone have any idea what might cause this problem?
Problem courtesy of: NullCrayfish
注意:本文来自Node.js Recipes。本站无法对本文内容的真实性、完整性、及时性、原创性提供任何保证,请您自行验证核实并承担相关的风险与后果!
CoLaBug.com遵循[CC BY-SA 4.0]分享并保持客观立场,本站不承担此类作品侵权行为的直接责任及连带责任。您有版权、意见、投诉等问题,请通过[eMail]联系我们处理,如需商业授权请联系原作者/原网站。
CoLaBug.com遵循[CC BY-SA 4.0]分享并保持客观立场,本站不承担此类作品侵权行为的直接责任及连带责任。您有版权、意见、投诉等问题,请通过[eMail]联系我们处理,如需商业授权请联系原作者/原网站。