aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-02-16 01:14:52 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2020-02-28 12:55:22 +0100
commit5ca1929e8cbc9beb32783a769e5a127527c1d93e (patch)
tree4721b25d9e07c22e13dcfcc39fa56a4f29cee7fb /lib/public
parentfed86e8382acb84b81e75e43fa9318700d5502ae (diff)
downloadnextcloud-server-5ca1929e8cbc9beb32783a769e5a127527c1d93e.tar.gz
nextcloud-server-5ca1929e8cbc9beb32783a769e5a127527c1d93e.zip
Create SimpleFile only when writing the content
instead of first creating an empty file and then writing the content. This solves the overhead of creating an empty file with the common pattern: ```php $file = $simpleFilder->newFile('foo.txt'); $file->putContent('bar.txt'); ``` roughly halving the number of storage and database operations that need to be done when creating a `SimpleFile`. This is not automatically done with `File` because that has a more complex api which I'm more hesitant to touch. Instead the `Folder::newFile` api has been extended to accept the content for the new file. In my local testing, the overhead of first creating an empty file took about 20% of the time for preview generation Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/Files/Folder.php3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php
index 99d331850cf..e7286ea028c 100644
--- a/lib/public/Files/Folder.php
+++ b/lib/public/Files/Folder.php
@@ -109,11 +109,12 @@ interface Folder extends Node {
* Create a new file
*
* @param string $path relative path of the new file
+ * @param string | resource | null $content content for the new file, since 19.0.0
* @return \OCP\Files\File
* @throws \OCP\Files\NotPermittedException
* @since 6.0.0
*/
- public function newFile($path);
+ public function newFile($path, $content = null);
/**
* search for files with the name matching $query