Skip to content

Commit

Permalink
fix(src): Fix the copy method in the Filesystem class to ensure that …
Browse files Browse the repository at this point in the history
…when a folder in source contains a folder with the same name as target, the files in the target folder are not overwritten.
  • Loading branch information
FaiZell committed Dec 6, 2024
1 parent 6f53e40 commit 83e135f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 83e135f

Please sign in to comment.