summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-06-07 16:50:51 +0200
committerRobin Appelman <robin@icewind.nl>2017-09-18 15:16:27 +0200
commit9b5accf9f369d53f085e42f139d879b2f4002f74 (patch)
tree5eb56391074fdfd77c19f916162ae3aaeae4060c /apps/files_external/lib
parentd70607104e7000ba008b4eb20bcf58a47b88fe35 (diff)
downloadnextcloud-server-9b5accf9f369d53f085e42f139d879b2f4002f74.tar.gz
nextcloud-server-9b5accf9f369d53f085e42f139d879b2f4002f74.zip
more efficient write only fopen
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index f26dcc3de02..2e343d8e469 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -42,6 +42,7 @@ use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\ObjectStore\S3ConnectionTrait;
use OC\Files\ObjectStore\S3ObjectTrait;
+use OCP\Constants;
class AmazonS3 extends \OC\Files\Storage\Common {
use S3ConnectionTrait;
@@ -339,6 +340,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
}
case 'w':
case 'wb':
+ $tmpFile = \OCP\Files::tmpFile();
+
+ $handle = fopen($tmpFile, 'w');
+ return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
+ $this->writeBack($tmpFile, $path);
+ });
case 'a':
case 'ab':
case 'r+':
@@ -506,11 +513,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
public function writeBack($tmpFile, $path) {
try {
- $source = $this->fopen($tmpFile, 'r');
+ $source = fopen($tmpFile, 'r');
$this->writeObject($path, $source);
fclose($source);
unlink($tmpFile);
+ return true;
} catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e);
return false;