mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-15 02:17:04 +01:00
Merge branch 'master-speed-up-uploads'
This commit is contained in:
commit
c47ffe187a
@ -401,6 +401,9 @@ class SFTP extends SSH2
|
|||||||
if (!defined('NET_SFTP_QUEUE_SIZE')) {
|
if (!defined('NET_SFTP_QUEUE_SIZE')) {
|
||||||
define('NET_SFTP_QUEUE_SIZE', 32);
|
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
|
$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"
|
// 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;
|
$sftp_packet_size-= strlen($handle) + 25;
|
||||||
$i = 0;
|
$i = $j = 0;
|
||||||
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
||||||
if ($dataCallback) {
|
if ($dataCallback) {
|
||||||
$temp = call_user_func($dataCallback, $sftp_packet_size);
|
$temp = call_user_func($dataCallback, $sftp_packet_size);
|
||||||
@ -1950,7 +1953,7 @@ class SFTP extends SSH2
|
|||||||
|
|
||||||
$subtemp = $offset + $sent;
|
$subtemp = $offset + $sent;
|
||||||
$packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp);
|
$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) {
|
if ($mode & self::SOURCE_LOCAL_FILE) {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
@ -1962,8 +1965,8 @@ class SFTP extends SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
$j++;
|
||||||
if ($i == NET_SFTP_QUEUE_SIZE) {
|
if ($i == NET_SFTP_UPLOAD_QUEUE_SIZE) {
|
||||||
if (!$this->read_put_responses($i)) {
|
if (!$this->read_put_responses($i)) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user