aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-06-07 16:50:51 +0200
committerRobin Appelman <robin@icewind.nl>2017-10-03 14:11:01 +0200
commitf45a7a43df7c3bcbfafbe5ad5698af4ffe2dd9fd (patch)
tree17ccd7a10ac136c232fd0bfd6e9522605002c0fc /apps/files_external
parent474c8aff292baa4f8d87bc4550bca6e0c4c52447 (diff)
downloadnextcloud-server-f45a7a43df7c3bcbfafbe5ad5698af4ffe2dd9fd.tar.gz
nextcloud-server-f45a7a43df7c3bcbfafbe5ad5698af4ffe2dd9fd.zip
more efficient write only fopen
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external')
-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;