Close the streams in writeStream even when there is an exception

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2020-04-08 16:40:56 +02:00 committed by backportbot[bot]
parent ad4c7bb30c
commit f72a44525a

View file

@ -853,9 +853,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
if (!$target) {
return 0;
}
list($count, $result) = \OC_Helper::streamCopy($stream, $target);
fclose($stream);
fclose($target);
try {
[$count, $result] = \OC_Helper::streamCopy($stream, $target);
} finally {
fclose($target);
fclose($stream);
}
return $count;
}
}