Merge pull request #20494 from nextcloud/backport/20361/stable17

[stable17] Close the streams in `writeStream` even when there is an exception
This commit is contained in:
Roeland Jago Douma 2020-04-15 21:12:25 +02:00 committed by GitHub
commit 20b11b8beb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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