diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-03-08 09:32:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 09:32:39 +0100 |
commit | 069e3f50a7b972535957ad605865d62d9ba91141 (patch) | |
tree | 706ae9e8090ede58e02d2832bfd24041cc578934 | |
parent | af55b03386ea7d18ba71da4f435106b5c661d641 (diff) | |
parent | 9764e70494a35c5112729847451794bfd40e61df (diff) | |
download | nextcloud-server-069e3f50a7b972535957ad605865d62d9ba91141.tar.gz nextcloud-server-069e3f50a7b972535957ad605865d62d9ba91141.zip |
Merge pull request #8711 from nextcloud/objectstore-write-only-fopen
don't read existing file when overwriting using object store
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 45c22a81a7b..84d714ce7de 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -261,6 +261,12 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { public function fopen($path, $mode) { $path = $this->normalizePath($path); + if (strrpos($path, '.') !== false) { + $ext = substr($path, strrpos($path, '.')); + } else { + $ext = ''; + } + switch ($mode) { case 'r': case 'rb': @@ -280,21 +286,21 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { } case 'w': case 'wb': + case 'w+': + case 'wb+': + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); + $handle = fopen($tmpFile, $mode); + return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { + $this->writeBack($tmpFile, $path); + }); case 'a': case 'ab': case 'r+': - case 'w+': - case 'wb+': case 'a+': case 'x': case 'x+': case 'c': case 'c+': - if (strrpos($path, '.') !== false) { - $ext = substr($path, strrpos($path, '.')); - } else { - $ext = ''; - } $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); if ($this->file_exists($path)) { $source = $this->fopen($path, 'r'); |