mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-28 10:10:08 +02:00
Make target dir before invoking "ln".
Fix bug with spaces in path.
This commit is contained in:
parent
9d30900798
commit
3a41a860d0
|
@ -4,6 +4,7 @@ namespace Mage\Task\BuiltIn\Filesystem;
|
||||||
use Mage\Task\AbstractTask;
|
use Mage\Task\AbstractTask;
|
||||||
use Mage\Task\Releases\IsReleaseAware;
|
use Mage\Task\Releases\IsReleaseAware;
|
||||||
use Mage\Task\SkipException;
|
use Mage\Task\SkipException;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LinkSharedFilesTask
|
* Class LinkSharedFilesTask
|
||||||
|
@ -70,26 +71,23 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
|
||||||
throw new SkipException('No files and folders configured for sym-linking.');
|
throw new SkipException('No files and folders configured for sym-linking.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sharedFolderName = $this->getParameter('shared', 'shared');
|
$remoteDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/';
|
||||||
$sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
|
$sharedFolderPath = $remoteDirectory . $this->getParameter('shared', 'shared');
|
||||||
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
|
$releasesDirectoryPath = $remoteDirectory . $this->getConfig()->release('directory', 'releases');
|
||||||
$releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
|
|
||||||
|
|
||||||
$currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId();
|
$currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId();
|
||||||
$relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/';
|
$fileSystem = new Filesystem();
|
||||||
|
|
||||||
foreach ($linkedEntities as $ePath) {
|
foreach ($linkedEntities as $ePath) {
|
||||||
list($entityPath, $strategy) = $this->getPath($ePath);
|
list($entityPath, $strategy) = $this->getPath($ePath);
|
||||||
$sharedEntityLinkedPath = "$sharedFolderPath/$entityPath";
|
if ($strategy === self::RELATIVE_LINKING) {
|
||||||
if ($strategy == self::RELATIVE_LINKING) {
|
$dirName = dirname($currentCopy . '/' . $entityPath);
|
||||||
$parentFolderPath = dirname($entityPath);
|
$target = $fileSystem->makePathRelative($sharedFolderPath, $dirName) . $entityPath;
|
||||||
$relativePath = $parentFolderPath == '.' ? $relativeDiffPath : $relativeDiffPath . $parentFolderPath . '/';
|
} else {
|
||||||
$sharedEntityLinkedPath = ltrim(
|
$target = $sharedFolderPath . '/' . $entityPath;
|
||||||
preg_replace('/(\w+\/)/', '../', $relativePath),
|
|
||||||
'/'
|
|
||||||
) . $sharedFolderName . '/' . $entityPath;
|
|
||||||
}
|
}
|
||||||
$command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath";
|
$command = 'mkdir -p ' . escapeshellarg(dirname($target));
|
||||||
|
$this->runCommandRemote($command);
|
||||||
|
$command = 'ln -nfs ' . escapeshellarg($target) . ' ' . escapeshellarg($currentCopy . '/' . $entityPath);
|
||||||
$this->runCommandRemote($command);
|
$this->runCommandRemote($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue