From: Julius Härtl Date: Wed, 9 Sep 2020 07:46:44 +0000 (+0200) Subject: Properly catch exception from writing to stream when copying a file X-Git-Tag: v20.0.0beta4~8^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1dddf6adc7b7e4654679dbe30ccbae4ed6ad740b;p=nextcloud-server.git Properly catch exception from writing to stream when copying a file Signed-off-by: Julius Härtl --- diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index ab6cd47ba5b..6a2bf6fe3a7 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -52,6 +52,7 @@ use OCP\Encryption\Exceptions\GenericEncryptionException; use OCP\Files\EntityTooLargeException; use OCP\Files\FileInfo; use OCP\Files\ForbiddenException; +use OCP\Files\GenericFileException; use OCP\Files\InvalidContentException; use OCP\Files\InvalidPathException; use OCP\Files\LockNotAcquiredException; @@ -200,8 +201,14 @@ class File extends Node implements IFile { $isEOF = feof($stream); }); - $count = $partStorage->writeStream($internalPartPath, $wrappedData); - $result = $count > 0; + $result = true; + $count = -1; + try { + $count = $partStorage->writeStream($internalPartPath, $wrappedData); + } catch (GenericFileException $e) { + $result = false; + } + if ($result === false) { $result = $isEOF;