]> source.dussan.org Git - nextcloud-server.git/commitdiff
allways fall back to fopen for encryption wrapper
authorRobin Appelman <robin@icewind.nl>
Wed, 31 Oct 2018 15:16:37 +0000 (16:16 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 31 Oct 2018 20:10:51 +0000 (21:10 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Storage/Wrapper/Encryption.php
lib/private/Files/Storage/Wrapper/Wrapper.php

index 42653b2d4a6ae575ca428bb04897dc106099a913..e1c1225e0cca00c1d9c33136dc44ace87d9dfd52 100644 (file)
@@ -1029,4 +1029,13 @@ class Encryption extends Wrapper {
 
        }
 
+       public function writeStream(string $path, $stream, int $size = null): int {
+               // always fall back to fopen
+               $target = $this->fopen($path, 'w');
+               list($count, $result) = \OC_Helper::streamCopy($stream, $target);
+               fclose($stream);
+               fclose($target);
+               return $count;
+       }
+
 }
index 060c596ad65dab46e18cb468ff7c9273afb3e9b2..f9c84b89fe51848a46c4de816dbd779f4dedc357 100644 (file)
@@ -32,9 +32,10 @@ namespace OC\Files\Storage\Wrapper;
 use OCP\Files\InvalidPathException;
 use OCP\Files\Storage\ILockingStorage;
 use OCP\Files\Storage\IStorage;
+use OCP\Files\Storage\IWriteStreamStorage;
 use OCP\Lock\ILockingProvider;
 
-class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
+class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStreamStorage {
        /**
         * @var \OC\Files\Storage\Storage $storage
         */
@@ -621,4 +622,18 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
        public function needsPartFile() {
                return $this->getWrapperStorage()->needsPartFile();
        }
+
+       public function writeStream(string $path, $stream, int $size = null): int {
+               $storage = $this->getWrapperStorage();
+               if ($storage->instanceOfStorage(IWriteStreamStorage::class)) {
+                       /** @var IWriteStreamStorage $storage */
+                       return $storage->writeStream($path, $stream, $size);
+               } else {
+                       $target = $this->fopen($path, 'w');
+                       list($count, $result) = \OC_Helper::streamCopy($stream, $target);
+                       fclose($stream);
+                       fclose($target);
+                       return $count;
+               }
+       }
 }