diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-02-14 16:46:30 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-02-15 08:41:39 +0100 |
commit | 3720add736e7a3974ff869d92bca5e454ec302a4 (patch) | |
tree | 231986ad36f34597010df1125aefcb1719beaa42 /apps/dav | |
parent | 61d66d79544e3bd17a4f96a569fc24596ec414db (diff) | |
download | nextcloud-server-3720add736e7a3974ff869d92bca5e454ec302a4.tar.gz nextcloud-server-3720add736e7a3974ff869d92bca5e454ec302a4.zip |
Add a wrapper to determine if a file is EOF
The stream is already closed at this point. Which means feof will always
return false. We have to determine if the stream is EOF in the
preCloseCallback. And pass this info along. Then the logic works as
expected.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/File.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index f948f0f552d..7767e83f508 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -36,6 +36,7 @@ namespace OCA\DAV\Connector\Sabre; +use Icewind\Streams\CallbackWrapper; use OC\AppFramework\Http\Request; use OC\Files\Filesystem; use OC\Files\View; @@ -166,10 +167,15 @@ class File extends Node implements IFile { } if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { - $count = $partStorage->writeStream($internalPartPath, $data); + $isEOF = false; + $wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function($stream) use (&$isEOF) { + $isEOF = feof($stream); + }); + + $count = $partStorage->writeStream($internalPartPath, $wrappedData); $result = $count > 0; if ($result === false) { - $result = feof($data); + $result = $isEOF; } } else { |