mirror of
https://github.com/danog/file.git
synced 2024-11-26 11:54:54 +01:00
Fix UV writing in append mode
This commit is contained in:
parent
94f772bd7a
commit
654596edeb
@ -176,10 +176,10 @@ class UvHandle implements Handle
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StatCache::clear($this->path);
|
StatCache::clear($this->path);
|
||||||
$newPosition = $this->position + $length;
|
$this->position += $length;
|
||||||
$delta = $newPosition - $this->position;
|
if ($this->position > $this->size) {
|
||||||
$this->position = ($this->mode[0] === "a") ? $this->position : $newPosition;
|
$this->size = $this->position;
|
||||||
$this->size += $delta;
|
}
|
||||||
$deferred->resolve($length);
|
$deferred->resolve($length);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -94,6 +94,23 @@ abstract class HandleTest extends TestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWriteInAppendMode()
|
||||||
|
{
|
||||||
|
$this->execute(function () {
|
||||||
|
$path = Fixture::path() . "/write";
|
||||||
|
/** @var \Amp\File\Handle $handle */
|
||||||
|
$handle = yield File\open($path, "a+");
|
||||||
|
$this->assertSame(0, $handle->tell());
|
||||||
|
yield $handle->write("bar");
|
||||||
|
yield $handle->write("foo");
|
||||||
|
yield $handle->write("baz");
|
||||||
|
$this->assertSame(9, $handle->tell());
|
||||||
|
yield $handle->seek(0);
|
||||||
|
$this->assertSame(0, $handle->tell());
|
||||||
|
$this->assertSame("barfoobaz", yield $handle->read());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function testReadingToEof()
|
public function testReadingToEof()
|
||||||
{
|
{
|
||||||
$this->execute(function () {
|
$this->execute(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user