Skip to content

Commit

Permalink
Merge branch '3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Feb 25, 2020
2 parents f1661a7 + 8c8e805 commit 0915176
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions phpseclib/Net/SFTP.php
Expand Up @@ -1568,6 +1568,13 @@ private function setstat_recursive($path, $attr, &$i)
}

$i++;

if ($i >= NET_SFTP_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
return false;
}
$i = 0;
}
}
}

Expand All @@ -1577,8 +1584,11 @@ private function setstat_recursive($path, $attr, &$i)

$i++;

if (!$this->read_put_responses($i)) {
return false;
if ($i >= NET_SFTP_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
return false;
}
$i = 0;
}

return true;
Expand Down Expand Up @@ -1940,7 +1950,7 @@ public function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -

$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, $i)) {
if (!$this->send_sftp_packet(NET_SFTP_WRITE, $packet)) {
if ($mode & self::SOURCE_LOCAL_FILE) {
fclose($fp);
}
Expand All @@ -1952,6 +1962,14 @@ public function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -
}

$i++;

if ($i == NET_SFTP_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
$i = 0;
break;
}
$i = 0;
}
}

if (!$this->read_put_responses($i)) {
Expand Down Expand Up @@ -2236,7 +2254,10 @@ public function delete($path, $recursive = true)
return false;
}

return $this->delete_recursive($path);
$i = 0;
$result = $this->delete_recursive($path, $i);
$this->read_put_responses($i);
return $result;
}

$this->remove_from_stat_cache($path);
Expand All @@ -2254,8 +2275,11 @@ public function delete($path, $recursive = true)
* @return bool
* @access private
*/
private function delete_recursive($path)
private function delete_recursive($path, &$i)
{
if (!$this->read_put_responses($i)) {
return false;
}
$i = 0;
$entries = $this->readlist($path, true);

Expand Down Expand Up @@ -2283,6 +2307,13 @@ private function delete_recursive($path)
$this->remove_from_stat_cache($temp);

$i++;

if ($i >= NET_SFTP_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
return false;
}
$i = 0;
}
}
}

Expand All @@ -2293,8 +2324,11 @@ private function delete_recursive($path)

$i++;

if (!$this->read_put_responses($i)) {
return false;
if ($i >= NET_SFTP_QUEUE_SIZE) {
if (!$this->read_put_responses($i)) {
return false;
}
$i = 0;
}

return true;
Expand Down

0 comments on commit 0915176

Please sign in to comment.