Merge branch '3.0-speed-up-uploads' into 3.0

This commit is contained in:
terrafrost 2020-03-07 22:21:48 -06:00
commit 0a6f457d14

View File

@ -401,6 +401,9 @@ class SFTP extends SSH2
if (!defined('NET_SFTP_QUEUE_SIZE')) {
define('NET_SFTP_QUEUE_SIZE', 32);
}
if (!defined('NET_SFTP_UPLOAD_QUEUE_SIZE')) {
define('NET_SFTP_UPLOAD_QUEUE_SIZE', 1024);
}
}
/**
@ -1934,7 +1937,7 @@ class SFTP extends SSH2
$sftp_packet_size = 4096; // PuTTY uses 4096
// make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header"
$sftp_packet_size-= strlen($handle) + 25;
$i = 0;
$i = $j = 0;
while ($dataCallback || ($size === 0 || $sent < $size)) {
if ($dataCallback) {
$temp = call_user_func($dataCallback, $sftp_packet_size);
@ -1950,7 +1953,7 @@ class SFTP extends SSH2
$subtemp = $offset + $sent;
$packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp);
if (!$this->send_sftp_packet(NET_SFTP_WRITE, $packet)) {
if (!$this->send_sftp_packet(NET_SFTP_WRITE, $packet, $j)) {
if ($mode & self::SOURCE_LOCAL_FILE) {
fclose($fp);
}
@ -1962,8 +1965,8 @@ class SFTP extends SSH2
}
$i++;
if ($i == NET_SFTP_QUEUE_SIZE) {
$j++;
if ($i == NET_SFTP_UPLOAD_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
$i = 0;
break;