aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/SimpleFS/SimpleFolder.php
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/private/Files/SimpleFS/SimpleFolder.php
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/private/Files/SimpleFS/SimpleFolder.php')
-rw-r--r--lib/private/Files/SimpleFS/SimpleFolder.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/private/Files/SimpleFS/SimpleFolder.php b/lib/private/Files/SimpleFS/SimpleFolder.php
index 833aa7d76cf..76f6a198e25 100644
--- a/lib/private/Files/SimpleFS/SimpleFolder.php
+++ b/lib/private/Files/SimpleFS/SimpleFolder.php
@@ -81,8 +81,7 @@ class SimpleFolder implements ISimpleFolder {
}
public function newFile($name) {
- $file = $this->folder->newFile($name);
-
- return new SimpleFile($file);
+ // delay creating the file until it's written to
+ return new NewSimpleFile($this->folder, $name);
}
}