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>
This commit is contained in:
Roeland Jago Douma 2019-02-14 16:46:30 +01:00
parent 61d66d7954
commit 3720add736
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -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 {