From 83e135fa42479d624c9e76c0d1b57b5d1b1cc4b7 Mon Sep 17 00:00:00 2001 From: faizel <15678863291@163.com> Date: Fri, 6 Dec 2024 22:04:03 +0800 Subject: [PATCH] fix(src): Fix the copy method in the Filesystem class to ensure that when a folder in source contains a folder with the same name as target, the files in the target folder are not overwritten. --- Filesystem.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Filesystem.php b/Filesystem.php index 2388e95..41a8757 100644 --- a/Filesystem.php +++ b/Filesystem.php @@ -21,7 +21,14 @@ public static function copy(string $source, string $target, bool $deleteSource = if ($file === '.' || $file === '..') { continue; } - \Nette\Utils\FileSystem::copy($source . '/' . $file, $target . '/' . $file); + + $sourcePath = $source . '/' . $file; + $targetPath = $target . '/' . $file; + if (is_dir($sourcePath)) { + self::copy($sourcePath, $targetPath, $deleteSource); + } else { + \Nette\Utils\FileSystem::copy($sourcePath, $targetPath); + } } if ($deleteSource) { \Nette\Utils\FileSystem::delete($source);