diff options
author | Robin Appelman <robin@icewind.nl> | 2023-08-29 22:14:46 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-09-04 16:30:09 +0200 |
commit | 9cf732a90b14d1e51c7a6946b34d9b117a25725b (patch) | |
tree | a8243cfa9c20252e8e917ffdf3b31ff570a3c7e9 /apps/files_external/lib/Lib | |
parent | 19daa7094706d99100cdf03235280b96468a21a1 (diff) | |
download | nextcloud-server-9cf732a90b14d1e51c7a6946b34d9b117a25725b.tar.gz nextcloud-server-9cf732a90b14d1e51c7a6946b34d9b117a25725b.zip |
fix error during sftp stream close
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SFTPReadStream.php | 7 |
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; } |