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>
pull/14210/head
Roeland Jago Douma 6 years ago
parent 61d66d7954
commit 3720add736
No known key found for this signature in database
GPG Key ID: F941078878347C0C
  1. 10
      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 {

Loading…
Cancel
Save