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 committed by backportbot[bot]
parent c8381c5d17
commit f5dec3702b
1 changed files with 9 additions and 2 deletions

View File

@ -51,6 +51,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;
@ -199,8 +200,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;