]> source.dussan.org Git - nextcloud-server.git/commit
Create SimpleFile only when writing the content
authorRobin Appelman <robin@icewind.nl>
Sun, 16 Feb 2020 00:14:52 +0000 (01:14 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 28 Feb 2020 11:55:22 +0000 (12:55 +0100)
commit5ca1929e8cbc9beb32783a769e5a127527c1d93e
tree4721b25d9e07c22e13dcfcc39fa56a4f29cee7fb
parentfed86e8382acb84b81e75e43fa9318700d5502ae
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>
lib/private/Files/Node/Folder.php
lib/private/Files/Node/LazyRoot.php
lib/private/Files/Node/NonExistingFolder.php
lib/private/Files/SimpleFS/NewSimpleFile.php [new file with mode: 0644]
lib/private/Files/SimpleFS/SimpleFolder.php
lib/public/Files/Folder.php