mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-27 04:34:45 +01:00
SFTP: optimize conditional calls to fclose in get() method
This commit is contained in:
parent
29e0143308
commit
cb66c561c2
@ -2032,12 +2032,14 @@ class Net_SFTP extends Net_SSH2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fclose_check = $local_file !== false && !is_resource($local_file);
|
||||||
|
|
||||||
$start = $offset;
|
$start = $offset;
|
||||||
$size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length;
|
$size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length;
|
||||||
while (true) {
|
while (true) {
|
||||||
$packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size);
|
$packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size);
|
||||||
if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) {
|
if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) {
|
||||||
if ($local_file !== false && !is_resource($local_file)) {
|
if ($fclose_check) {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2060,7 +2062,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
break 2;
|
break 2;
|
||||||
default:
|
default:
|
||||||
user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS');
|
user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS');
|
||||||
if ($local_file !== false && !is_resource($local_file)) {
|
if ($fclose_check) {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2079,7 +2081,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($local_file !== false && !is_resource($local_file)) {
|
if ($fclose_check) {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user