diff --git a/src/Methods/CopyMethod.php b/src/Methods/CopyMethod.php index 0bcc1b2..2b91717 100644 --- a/src/Methods/CopyMethod.php +++ b/src/Methods/CopyMethod.php @@ -26,10 +26,10 @@ public function __construct(Filesystem $filesystem = null) public function exposeDirectory($source, $target) { - // Skip if symlink - if ($this->filesystem->isSymlinkedDirectory($target)) { - $this->filesystem->unlink($target); - } + // Remove destination directory to ensure it is clean + $this->filesystem->removeDirectory($target); + + // Copy to destination if (!$this->copy($source, $target)) { throw new RuntimeException("Could not write to directory $target"); } diff --git a/src/Methods/SymlinkMethod.php b/src/Methods/SymlinkMethod.php index 2ea49da..47d0095 100644 --- a/src/Methods/SymlinkMethod.php +++ b/src/Methods/SymlinkMethod.php @@ -24,13 +24,13 @@ public function __construct(Filesystem $filesystem = null) public function exposeDirectory($source, $target) { + // Remove destination directory to ensure it is clean + $this->filesystem->removeDirectory($target); + + // Ensure parent dir exist $parent = dirname($target); $this->filesystem->ensureDirectoryExists($parent); - // Delete target if exists - if (file_exists($target)) { - $this->filesystem->removeDirectory($target); - } // Ensure symlink exists if (!$this->filesystem->relativeSymlink($source, $target)) { throw new RuntimeException("Could not create symlink at $target");