diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php index 887b082a621..c50378ea214 100644 --- a/lib/private/Streamer.php +++ b/lib/private/Streamer.php @@ -8,6 +8,7 @@ namespace OC; +use Icewind\Streams\CallbackWrapper; use OC\Files\Filesystem; use OCP\Files\File; use OCP\Files\Folder; @@ -126,6 +127,7 @@ class Streamer { /** @var LoggerInterface $logger */ $logger = Server::get(LoggerInterface::class); foreach ($files as $file) { + if(connection_status() !== CONNECTION_NORMAL) return; if ($file instanceof File) { try { $fh = $file->fopen('r'); @@ -161,6 +163,15 @@ class Streamer { * @return bool $success */ public function addFileFromStream($stream, string $internalName, int|float $size, $time): bool { + if(connection_status() !== CONNECTION_NORMAL) return false; + // Close file-stream when user-connection closed + $stream = CallbackWrapper::wrap($stream, + function ($count) use ($stream) { + if (connection_status() !== CONNECTION_NORMAL) { + fclose($stream); + } + }); + $options = []; if ($time) { $options = [