1
0
mirror of https://github.com/danog/file.git synced 2024-11-26 20:04:51 +01:00

Don't fail if directory exists on recursive creation

This commit is contained in:
Niklas Keller 2023-02-18 17:32:06 +01:00
parent a631384d3e
commit b8e3314417
No known key found for this signature in database
GPG Key ID: AFA536ABA90C76A6
3 changed files with 22 additions and 1 deletions

View File

@ -233,6 +233,13 @@ final class EioFilesystemDriver implements FilesystemDriver
try {
$deferred->getFuture()->await();
} catch (FilesystemException $exception) {
$result = $this->getStatus($path);
if ($result !== null && ($result['mode'] & 0040000)) {
return;
}
throw $exception;
} finally {
$this->poll->done();
}

View File

@ -266,6 +266,13 @@ final class UvFilesystemDriver implements FilesystemDriver
try {
$deferred->getFuture()->await();
} catch (FilesystemException $exception) {
$result = $this->getStatus($path);
if ($result !== null && ($result['mode'] & 0040000)) {
return;
}
throw $exception;
} finally {
$this->poll->done();
}

View File

@ -386,13 +386,20 @@ abstract class FilesystemDriverTest extends FilesystemTest
$this->assertTrue($this->driver->exists($dir));
}
public function testCreateDirectoryRecursivelyExists(): void
public function testCreateDirectoryRecursivelyExistsDir(): void
{
$this->expectNotToPerformAssertions();
$this->driver->createDirectoryRecursively(__DIR__, 0764);
}
public function testCreateDirectoryRecursivelyExistsFile(): void
{
$this->expectException(FilesystemException::class);
$this->driver->createDirectoryRecursively(__FILE__, 0764);
}
public function testCreateDirectoryFailsOnNonexistentPath(): void
{
$fixtureDir = Fixture::path();