]> source.dussan.org Git - nextcloud-server.git/commitdiff
Close the streams in `writeStream` even when there is an exception 20493/head
authorRobin Appelman <robin@icewind.nl>
Wed, 8 Apr 2020 14:40:56 +0000 (16:40 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 15 Apr 2020 08:49:53 +0000 (08:49 +0000)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Storage/Common.php

index 8760fae1185f50bbb9e02fc4e1d5f06b2409876e..82ac49b9fdfb3fba8f1d196f02ea714099023847 100644 (file)
@@ -857,9 +857,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;
        }
 }