Fix archive command crashing if a path cannot be realpathed on windows, fixes #11544
parent
68f6498bd3
commit
bd03981ea7
|
@ -47,7 +47,11 @@ class ArchivableFilesFinder extends FilterIterator
|
|||
{
|
||||
$fs = new Filesystem();
|
||||
|
||||
$sources = $fs->normalizePath(realpath($sources));
|
||||
$sourcesRealPath = realpath($sources);
|
||||
if ($sourcesRealPath === false) {
|
||||
throw new \RuntimeException('Could not realpath() the source directory "'.$sources.'"');
|
||||
}
|
||||
$sources = $fs->normalizePath($sourcesRealPath);
|
||||
|
||||
if ($ignoreFilters) {
|
||||
$filters = [];
|
||||
|
@ -61,14 +65,18 @@ class ArchivableFilesFinder extends FilterIterator
|
|||
$this->finder = new Finder();
|
||||
|
||||
$filter = static function (\SplFileInfo $file) use ($sources, $filters, $fs): bool {
|
||||
if ($file->isLink() && ($file->getRealPath() === false || strpos($file->getRealPath(), $sources) !== 0)) {
|
||||
$realpath = $file->getRealPath();
|
||||
if ($realpath === false) {
|
||||
return false;
|
||||
}
|
||||
if ($file->isLink() && strpos($realpath, $sources) !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$relativePath = Preg::replace(
|
||||
'#^'.preg_quote($sources, '#').'#',
|
||||
'',
|
||||
$fs->normalizePath($file->getRealPath())
|
||||
$fs->normalizePath($realpath)
|
||||
);
|
||||
|
||||
$exclude = false;
|
||||
|
@ -79,10 +87,6 @@ class ArchivableFilesFinder extends FilterIterator
|
|||
return !$exclude;
|
||||
};
|
||||
|
||||
if (method_exists($filter, 'bindTo')) {
|
||||
$filter = $filter->bindTo(null);
|
||||
}
|
||||
|
||||
$this->finder
|
||||
->in($sources)
|
||||
->filter($filter)
|
||||
|
|
Loading…
Reference in New Issue