From 9b3cc72f7c033c4dba9a2b1e21e0e38f488318b5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 31 Oct 2018 19:41:55 +0100 Subject: fix writeStream for jail wrapper Signed-off-by: Robin Appelman --- lib/private/Files/Storage/Common.php | 3 +++ lib/private/Files/Storage/Wrapper/Jail.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 6324050b472..72fe3a79792 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -821,6 +821,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { */ public function writeStream(string $path, $stream, int $size = null): int { $target = $this->fopen($path, 'w'); + if (!$target) { + return 0; + } list($count, $result) = \OC_Helper::streamCopy($stream, $target); fclose($stream); fclose($target); diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 56514af6d80..f21b5716467 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -29,6 +29,7 @@ use OC\Files\Cache\Wrapper\CacheJail; use OC\Files\Cache\Wrapper\JailPropagator; use OC\Files\Filesystem; use OCP\Files\Storage\IStorage; +use OCP\Files\Storage\IWriteStreamStorage; use OCP\Lock\ILockingProvider; /** @@ -515,4 +516,18 @@ class Jail extends Wrapper { $this->propagator = new JailPropagator($storage, \OC::$server->getDatabaseConnection()); return $this->propagator; } + + public function writeStream(string $path, $stream, int $size = null): int { + $storage = $this->getWrapperStorage(); + if ($storage->instanceOfStorage(IWriteStreamStorage::class)) { + /** @var IWriteStreamStorage $storage */ + return $storage->writeStream($this->getUnjailedPath($path), $stream, $size); + } else { + $target = $this->fopen($path, 'w'); + list($count, $result) = \OC_Helper::streamCopy($stream, $target); + fclose($stream); + fclose($target); + return $count; + } + } } -- cgit v1.2.3