mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 05:22:35 +09:00
Fix UnexpectedValueException if there are permission problems deep inside a directory tree
This commit is contained in:
parent
06f4eca47a
commit
178add54e8
1 changed files with 47 additions and 37 deletions
|
|
@ -672,25 +672,26 @@ class Storage
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
|
$iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
|
||||||
}
|
|
||||||
catch (\UnexpectedValueException $e)
|
|
||||||
{
|
|
||||||
trigger_error('Cannot read directory: ' . $dirname, \E_USER_WARNING);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($iterator as $fileinfo)
|
foreach ($iterator as $fileinfo)
|
||||||
{
|
|
||||||
if (!$skip_subdirs || !is_dir($fileinfo))
|
|
||||||
{
|
{
|
||||||
$basename = basename($fileinfo);
|
if (!$skip_subdirs || !is_dir($fileinfo))
|
||||||
if (!$skip_dotfiles || $basename[0] !== '.')
|
|
||||||
{
|
{
|
||||||
$result[] = $full_path ? $fileinfo : $basename;
|
$basename = basename($fileinfo);
|
||||||
|
if (!$skip_dotfiles || $basename[0] !== '.')
|
||||||
|
{
|
||||||
|
$result[] = $full_path ? $fileinfo : $basename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (\UnexpectedValueException $e)
|
||||||
|
{
|
||||||
|
trigger_error($e->getMessage(), \E_USER_WARNING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sort($result);
|
sort($result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
@ -720,38 +721,47 @@ class Storage
|
||||||
|
|
||||||
$rdi_options = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS;
|
$rdi_options = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS;
|
||||||
$rii_options = \RecursiveIteratorIterator::CHILD_FIRST;
|
$rii_options = \RecursiveIteratorIterator::CHILD_FIRST;
|
||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, $rdi_options), $rii_options);
|
|
||||||
|
|
||||||
foreach ($iterator as $path)
|
try
|
||||||
{
|
{
|
||||||
$path_source = $path->getPathname();
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, $rdi_options), $rii_options);
|
||||||
if (strpos($path_source, $source) !== 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($exclude_regexp && preg_match($exclude_regexp, $path_source))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path_destination = $destination . substr($path_source, strlen($source));
|
foreach ($iterator as $path)
|
||||||
if ($path->isDir())
|
|
||||||
{
|
{
|
||||||
$status = self::isDirectory($path_destination) || self::createDirectory($path_destination, $path->getPerms());
|
$path_source = $path->getPathname();
|
||||||
if (!$status)
|
if (strpos($path_source, $source) !== 0)
|
||||||
{
|
{
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
if ($exclude_regexp && preg_match($exclude_regexp, $path_source))
|
||||||
else
|
{
|
||||||
{
|
continue;
|
||||||
$status = self::copy($path_source, $path_destination, $path->getPerms());
|
}
|
||||||
if (!$status)
|
|
||||||
{
|
$path_destination = $destination . substr($path_source, strlen($source));
|
||||||
return false;
|
if ($path->isDir())
|
||||||
|
{
|
||||||
|
$status = self::isDirectory($path_destination) || self::createDirectory($path_destination, $path->getPerms());
|
||||||
|
if (!$status)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$status = self::copy($path_source, $path_destination, $path->getPerms());
|
||||||
|
if (!$status)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (\UnexpectedValueException $e)
|
||||||
|
{
|
||||||
|
trigger_error($e->getMessage(), \E_USER_WARNING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue