using mkdir() in copyThenRemove() leads to errors if the target exists or not a dir, use ensureDirectoryExists() instead
parent
b333d7a485
commit
dd4db91ae7
|
@ -129,15 +129,12 @@ class Filesystem
|
|||
{
|
||||
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
if (!file_exists($target)) {
|
||||
mkdir($target, 0777, true);
|
||||
}
|
||||
$this->ensureDirectoryExists($target);
|
||||
|
||||
foreach ($ri as $file) {
|
||||
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
|
||||
if ($file->isDir()) {
|
||||
mkdir($targetPath);
|
||||
$this->ensureDirectoryExists($targetPath);
|
||||
} else {
|
||||
copy($file->getPathname(), $targetPath);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue