Skip to content

Commit

Permalink
Ensure destination directory is clean before copying assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Sep 26, 2017
1 parent 4ee94f3 commit 902728d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Methods/CopyMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
8 changes: 4 additions & 4 deletions src/Methods/SymlinkMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 902728d

Please sign in to comment.