Properly catch exception from writing to stream when copying a file

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-09-09 09:46:44 +02:00
parent 9780c4f755
commit 1dddf6adc7
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 9 additions and 2 deletions

View File

@ -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;