mirror of
https://github.com/danog/file.git
synced 2024-11-30 04:19:39 +01:00
Fixes invalid stat result in UvDriver
This commit is contained in:
parent
836e0ebb03
commit
3e5da2b245
@ -123,6 +123,14 @@ class UvDriver implements Driver {
|
|||||||
if (empty($fh)) {
|
if (empty($fh)) {
|
||||||
$stat = null;
|
$stat = null;
|
||||||
} else {
|
} else {
|
||||||
|
// link is not a valid stat type but returned by the uv extension
|
||||||
|
// change link to nlink
|
||||||
|
if (isset($stat['link'])) {
|
||||||
|
$stat['nlink'] = $stat['link'];
|
||||||
|
|
||||||
|
unset($stat['link']);
|
||||||
|
}
|
||||||
|
|
||||||
StatCache::set($path, $stat);
|
StatCache::set($path, $stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ abstract class DriverTest extends TestCase {
|
|||||||
$fixtureDir = Fixture::path();
|
$fixtureDir = Fixture::path();
|
||||||
$stat = (yield File\stat("{$fixtureDir}/small.txt"));
|
$stat = (yield File\stat("{$fixtureDir}/small.txt"));
|
||||||
$this->assertInternalType("array", $stat);
|
$this->assertInternalType("array", $stat);
|
||||||
|
$this->assertStatSame(\stat("{$fixtureDir}/small.txt"), $stat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ abstract class DriverTest extends TestCase {
|
|||||||
$fixtureDir = Fixture::path();
|
$fixtureDir = Fixture::path();
|
||||||
$stat = (yield File\stat("{$fixtureDir}/dir"));
|
$stat = (yield File\stat("{$fixtureDir}/dir"));
|
||||||
$this->assertInternalType("array", $stat);
|
$this->assertInternalType("array", $stat);
|
||||||
|
$this->assertStatSame(\stat("{$fixtureDir}/dir"), $stat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +330,24 @@ abstract class DriverTest extends TestCase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assertStatSame(array $expected, array $actual) {
|
||||||
|
$filter = function (array $stat) {
|
||||||
|
$filtered = \array_filter(
|
||||||
|
$stat,
|
||||||
|
function (string $key): bool {
|
||||||
|
return !\is_numeric($key);
|
||||||
|
},
|
||||||
|
ARRAY_FILTER_USE_KEY
|
||||||
|
);
|
||||||
|
|
||||||
|
ksort($filtered);
|
||||||
|
|
||||||
|
return $filtered;
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->assertSame($filter($expected), $filter($actual));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $stat
|
* @param array $stat
|
||||||
* @return string
|
* @return string
|
||||||
|
Loading…
Reference in New Issue
Block a user