is_dir($source)) { if ($this->file_exists($target)) { $this->unlink($target); } $this->mkdir($target); return $this->copyRecursive($source, $target); } else { return parent::copy($source, $target); } } /** * For adapters that don't support copying folders natively */ protected function copyRecursive(string $source, string $target): bool { $dh = $this->opendir($source); $result = true; while (($file = readdir($dh)) !== false) { if (!\OC\Files\Filesystem::isIgnoredDir($file)) { if ($this->is_dir($source . '/' . $file)) { $this->mkdir($target . '/' . $file); $result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file); } else { $result = parent::copy($source . '/' . $file, $target . '/' . $file); } if (!$result) { break; } } } return $result; } }