/** * @param PackageInterface $initial * @param PackageInterface $target */ protected function updateCode(PackageInterface $initial, PackageInterface $target) { $initialDownloadPath = $this->getInstallPath($initial); $targetDownloadPath = $this->getInstallPath($target); if ($targetDownloadPath !== $initialDownloadPath) { // if the target and initial dirs intersect, we force a remove + install // to avoid the rename wiping the target dir as part of the initial dir cleanup if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath) { $this->removeCode($initial); $this->installCode($target); return; } $this->filesystem->rename($initialDownloadPath, $targetDownloadPath); } $this->downloadManager->update($initial, $target, $targetDownloadPath); }
/** * @param \Composer\Package\PackageInterface $initial * @param \Composer\Package\PackageInterface $target */ protected function updateCode(\Composer\Package\PackageInterface $initial, \Composer\Package\PackageInterface $target) { // Currently the install path for all versions is the same. // In the future the install path for two core versions may differ. $initialDownloadPath = $this->getInstallPath($initial); $targetDownloadPath = $this->getInstallPath($target); if ($targetDownloadPath !== $initialDownloadPath) { // if the target and initial dirs intersect, we force a remove + install // to avoid the rename wiping the target dir as part of the initial dir cleanup if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath) { $this->removeCode($initial); $this->installCode($target); return; } $this->filesystem->rename($initialDownloadPath, $targetDownloadPath); } $this->downloadManager->update($initial, $target, $targetDownloadPath); }
/** * Download or update a package. * * @param Composer $composer * @param PackageInterface $package * @param OutputInterface $output * @param string $targetDir * @param PackageInterface $initialPackage */ protected function fetchPackage(DownloadManager $manager, PackageInterface $package, $targetDir, PackageInterface $initialPackage = null) { // Better to download the sources $manager->setPreferSource(true); if (null !== $initialPackage) { $manager->update($initialPackage, $package, $targetDir); } else { $manager->download($package, $targetDir); } }