mirror of
https://github.com/danog/file.git
synced 2024-11-26 11:54:54 +01:00
EioDriver and UvDriver did not pass O_TRUNC in file\put
Also prepare tag 0.1.3
This commit is contained in:
parent
ada86677c9
commit
6612ae6757
@ -1,3 +1,8 @@
|
|||||||
|
### 0.1.3
|
||||||
|
|
||||||
|
- Add recursive mkdir()
|
||||||
|
- EioDriver and UvDriver now pass O_TRUNC in file\put()
|
||||||
|
|
||||||
### 0.1.2
|
### 0.1.2
|
||||||
|
|
||||||
- Make UvHandle throw FilesystemException instead of \RuntimeException
|
- Make UvHandle throw FilesystemException instead of \RuntimeException
|
||||||
|
@ -538,7 +538,7 @@ class EioDriver implements Driver {
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function put($path, $contents) {
|
public function put($path, $contents) {
|
||||||
$flags = \EIO_O_RDWR | \EIO_O_CREAT;
|
$flags = \EIO_O_RDWR | \EIO_O_CREAT | \EIO_O_TRUNC;
|
||||||
$mode = \EIO_S_IRUSR | \EIO_S_IWUSR | \EIO_S_IXUSR;
|
$mode = \EIO_S_IRUSR | \EIO_S_IWUSR | \EIO_S_IXUSR;
|
||||||
$priority = \EIO_PRI_DEFAULT;
|
$priority = \EIO_PRI_DEFAULT;
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ class UvDriver implements Driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function doPut($path, $contents): \Generator {
|
private function doPut($path, $contents): \Generator {
|
||||||
$flags = \UV::O_WRONLY | \UV::O_CREAT;
|
$flags = \UV::O_WRONLY | \UV::O_CREAT | \UV::O_TRUNC;
|
||||||
$mode = \UV::S_IRWXU | \UV::S_IRUSR;
|
$mode = \UV::S_IRWXU | \UV::S_IRUSR;
|
||||||
$this->reactor->addRef();
|
$this->reactor->addRef();
|
||||||
$promise = $this->doFsOpen($path, $flags, $mode);
|
$promise = $this->doFsOpen($path, $flags, $mode);
|
||||||
|
@ -243,6 +243,21 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPutTruncates() {
|
||||||
|
amp\run(function () {
|
||||||
|
$fixturePath = self::getFixturePath() . "/trunc";
|
||||||
|
$contents = "long data";
|
||||||
|
$short = "data";
|
||||||
|
|
||||||
|
yield file\put($fixturePath, $contents);
|
||||||
|
yield file\put($fixturePath, $short);
|
||||||
|
$contents2 = (yield file\get($fixturePath));
|
||||||
|
yield file\unlink($fixturePath);
|
||||||
|
|
||||||
|
$this->assertSame($short, $contents2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function testUnlink() {
|
public function testUnlink() {
|
||||||
amp\run(function () {
|
amp\run(function () {
|
||||||
$fixtureDir = self::getFixturePath();
|
$fixtureDir = self::getFixturePath();
|
||||||
|
Loading…
Reference in New Issue
Block a user