Scott C Wilson
Scott C Wilson

Reputation: 20026

Is phpseclib's sftp put command synchronous?

I'm doing a put, then removing the file, i.e.

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

Is this safe, or is put asynchronous?

Upvotes: 1

Views: 171

Answers (1)

neubert
neubert

Reputation: 16802

It's synchronous. Under the hood it basically just does a while loop

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

$size is defined as the size of the local file:

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.

Eventually, the amount of sent data will meet (or exceed) the size of the file and the whole loop will break.

Upvotes: 1

Related Questions