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
parent 981278a666
commit ccbf3059ba
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 6 additions and 3 deletions

View File

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