summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-08-29 22:14:46 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-09-18 17:33:42 +0000
commit0a219b1dc04278430274c53be1810b9da56f0f21 (patch)
tree3a5487a31b0a1b6f6f94b3984f2830628de4d6ac /apps
parent70658918d918027c4f6b1e4529ccd93cdd71c75e (diff)
downloadnextcloud-server-0a219b1dc04278430274c53be1810b9da56f0f21.tar.gz
nextcloud-server-0a219b1dc04278430274c53be1810b9da56f0f21.zip
fix error during sftp stream close
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTPReadStream.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SFTPReadStream.php b/apps/files_external/lib/Lib/Storage/SFTPReadStream.php
index c4749b15453..7a53f41aa61 100644
--- a/apps/files_external/lib/Lib/Storage/SFTPReadStream.php
+++ b/apps/files_external/lib/Lib/Storage/SFTPReadStream.php
@@ -49,6 +49,7 @@ class SFTPReadStream implements File {
private $eof = false;
private $buffer = '';
+ private bool $pendingRead = false;
public static function register($protocol = 'sftpread') {
if (in_array($protocol, stream_get_wrappers(), true)) {
@@ -143,10 +144,12 @@ class SFTPReadStream implements File {
private function request_chunk($size) {
$packet = pack('Na*N3', strlen($this->handle), $this->handle, $this->internalPosition / 4294967296, $this->internalPosition, $size);
+ $this->pendingRead = true;
return $this->sftp->_send_sftp_packet(NET_SFTP_READ, $packet);
}
private function read_chunk() {
+ $this->pendingRead = false;
$response = $this->sftp->_get_sftp_packet();
switch ($this->sftp->packet_type) {
@@ -195,6 +198,10 @@ class SFTPReadStream implements File {
}
public function stream_close() {
+ // we still have a read request incoming that needs to be handled before we can close
+ if ($this->pendingRead) {
+ $this->sftp->_get_sftp_packet();
+ }
if (!$this->sftp->_close_handle($this->handle)) {
return false;
}