简体   繁体   English

phpseclib 的 sftp put 命令是同步的吗?

[英]Is phpseclib's sftp put command synchronous?

I'm doing a put , then removing the file, ie我正在做一个put ,然后删除文件,即

$sftp->put($filename_dest, $filename, NET_SFTP_LOCAL_FILE);
unlink($filename); 

Is this safe, or is put asynchronous?这是安全的,或者是put异步?

It's synchronous.它是同步的。 Under the hood it basically just does a while loop在引擎盖下它基本上只是做一个 while 循环

https://github.com/phpseclib/phpseclib/blob/2.0.14/phpseclib/Net/SFTP.php#L2011 https://github.com/phpseclib/phpseclib/blob/2.0.14/phpseclib/Net/SFTP.php#L2011

$size is defined as the size of the local file: $size定义为本地文件的大小:

https://github.com/phpseclib/phpseclib/blob/2.0.14/phpseclib/Net/SFTP.php#L1990 https://github.com/phpseclib/phpseclib/blob/2.0.14/phpseclib/Net/SFTP.php#L1990

$sent starts off at 0 and is incremented by the size of the data that's being sent over during each loop. $sent从 0 开始,并根据每次循环期间发送的数据大小递增。

Eventually, the amount of sent data will meet (or exceed) the size of the file and the whole loop will break.最终,发送的数据量将达到(或超过)文件的大小,整个循环将中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM