mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01: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\Releases\IsReleaseAware;
 | 
			
		||||
use Mage\Task\SkipException;
 | 
			
		||||
use Symfony\Component\Filesystem\Filesystem;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class LinkSharedFilesTask
 | 
			
		||||
@ -70,26 +71,23 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
 | 
			
		||||
            throw new SkipException('No files and folders configured for sym-linking.');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $sharedFolderName = $this->getParameter('shared', 'shared');
 | 
			
		||||
        $sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
 | 
			
		||||
        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
			
		||||
        $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
			
		||||
 | 
			
		||||
        $remoteDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/';
 | 
			
		||||
        $sharedFolderPath = $remoteDirectory . $this->getParameter('shared', 'shared');
 | 
			
		||||
        $releasesDirectoryPath = $remoteDirectory . $this->getConfig()->release('directory', 'releases');
 | 
			
		||||
        $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId();
 | 
			
		||||
        $relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/';
 | 
			
		||||
        $fileSystem = new Filesystem();
 | 
			
		||||
 | 
			
		||||
        foreach ($linkedEntities as $ePath) {
 | 
			
		||||
            list($entityPath, $strategy) = $this->getPath($ePath);
 | 
			
		||||
            $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath";
 | 
			
		||||
            if ($strategy == self::RELATIVE_LINKING) {
 | 
			
		||||
                $parentFolderPath = dirname($entityPath);
 | 
			
		||||
                $relativePath = $parentFolderPath == '.' ? $relativeDiffPath : $relativeDiffPath . $parentFolderPath . '/';
 | 
			
		||||
                $sharedEntityLinkedPath = ltrim(
 | 
			
		||||
                        preg_replace('/(\w+\/)/', '../', $relativePath),
 | 
			
		||||
                        '/'
 | 
			
		||||
                    ) . $sharedFolderName . '/' . $entityPath;
 | 
			
		||||
            if ($strategy === self::RELATIVE_LINKING) {
 | 
			
		||||
                $dirName = dirname($currentCopy . '/' . $entityPath);
 | 
			
		||||
                $target = $fileSystem->makePathRelative($sharedFolderPath, $dirName) . $entityPath;
 | 
			
		||||
            } else {
 | 
			
		||||
                $target = $sharedFolderPath . '/' . $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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user