Skip to content

Commit

Permalink
Fix touch on non-existent files in uv / eio drivers
Browse files Browse the repository at this point in the history
Fixes #73.
  • Loading branch information
kelunik committed Jul 23, 2023
1 parent c2313ea commit efeb737
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Driver/EioFilesystemDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ public function touch(string $path, ?int $modificationTime, ?int $accessTime): v
$modificationTime = $modificationTime ?? \time();
$accessTime = $accessTime ?? $modificationTime;

if (!$this->getStatus($path)) {
$this->openFile($path, 'c')->close();
}

$deferred = new DeferredFuture;
$this->poll->listen();

Expand Down
4 changes: 4 additions & 0 deletions src/Driver/UvFilesystemDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ public function touch(string $path, ?int $modificationTime, ?int $accessTime): v
$modificationTime = $modificationTime ?? \time();
$accessTime = $accessTime ?? $modificationTime;

if (!$this->getStatus($path)) {
$this->openFile($path, 'c')->close();
}

$deferred = new DeferredFuture;
$this->poll->listen();

Expand Down
3 changes: 3 additions & 0 deletions test/FilesystemDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ public function testTouch(): void

$this->assertTrue($newStat["atime"] > $oldStat["atime"]);
$this->assertTrue($newStat["mtime"] > $oldStat["mtime"]);

$this->driver->touch($touch);
self::assertFileExists($touch);
}

/**
Expand Down

0 comments on commit efeb737

Please sign in to comment.