Skip to content

Commit efeb737

Browse files
committed
Fix touch on non-existent files in uv / eio drivers
Fixes #73.
1 parent c2313ea commit efeb737

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/Driver/EioFilesystemDriver.php

+4
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ public function touch(string $path, ?int $modificationTime, ?int $accessTime): v
313313
$modificationTime = $modificationTime ?? \time();
314314
$accessTime = $accessTime ?? $modificationTime;
315315

316+
if (!$this->getStatus($path)) {
317+
$this->openFile($path, 'c')->close();
318+
}
319+
316320
$deferred = new DeferredFuture;
317321
$this->poll->listen();
318322

src/Driver/UvFilesystemDriver.php

+4
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ public function touch(string $path, ?int $modificationTime, ?int $accessTime): v
363363
$modificationTime = $modificationTime ?? \time();
364364
$accessTime = $accessTime ?? $modificationTime;
365365

366+
if (!$this->getStatus($path)) {
367+
$this->openFile($path, 'c')->close();
368+
}
369+
366370
$deferred = new DeferredFuture;
367371
$this->poll->listen();
368372

test/FilesystemDriverTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ public function testTouch(): void
504504

505505
$this->assertTrue($newStat["atime"] > $oldStat["atime"]);
506506
$this->assertTrue($newStat["mtime"] > $oldStat["mtime"]);
507+
508+
$this->driver->touch($touch);
509+
self::assertFileExists($touch);
507510
}
508511

509512
/**

0 commit comments

Comments
 (0)