Skip to content

Commit 9b0cf98

Browse files
author
Charlotte Dunois
committed
Update tail example
We need to open a file descriptor manually, as if we were to open a stream, the stream would read the complete file and then close the file descriptor.
1 parent 373d705 commit 9b0cf98

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

examples/tail.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
echo $content;
1313

1414
$lastSize = strlen($content);
15+
$adapter = $filesystem->getAdapter();
1516

16-
$file = $filesystem->file($path);
17-
18-
$file->open('r')->then(function (\React\Stream\ReadableStreamInterface $stream) use ($filesystem, $loop, $file, &$lastSize) {
19-
/** @var \React\Filesystem\Stream\GenericStreamInterface $stream */
20-
$fileDescriptor = $stream->getFiledescriptor();
21-
22-
$adapter = $filesystem->getAdapter();
17+
$adapter->open($path, 'r')->then(function ($fileDescriptor) use ($adapter, $filesystem, $loop, $path, &$lastSize) {
18+
$file = $filesystem->file($path);
2319

2420
$loop->addPeriodicTimer(1, function () use ($adapter, $fileDescriptor, $file, &$lastSize) {
2521
$file->size()->then(function ($size) use ($adapter, $fileDescriptor, &$lastSize) {

0 commit comments

Comments
 (0)