]> source.dussan.org Git - nextcloud-server.git/commitdiff
Close the streams in `writeStream` even when there is an exception 20361/head
authorRobin Appelman <robin@icewind.nl>
Wed, 8 Apr 2020 14:40:56 +0000 (16:40 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 8 Apr 2020 14:40:56 +0000 (16:40 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Storage/Common.php

index f2d427227c98de74d33695937d2e439788b8fdeb..1921e5f21d7fd4ab56a8ac3d709ec11fe30d39d0 100644 (file)
@@ -858,9 +858,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;
        }
 }