From 15a448fe343def838ef97b9d3154b5aa9b34a1fe Mon Sep 17 00:00:00 2001 From: Aaron Latham-Ilari Date: Tue, 12 Aug 2014 14:42:12 +1200 Subject: [PATCH] fixes some issues with always-install option --- ...onDestructiveArchiveInstallerInstaller.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ABC/Composer/NonDestructiveArchiveInstallerInstaller.php b/src/ABC/Composer/NonDestructiveArchiveInstallerInstaller.php index 174bce3..d3b4c7f 100644 --- a/src/ABC/Composer/NonDestructiveArchiveInstallerInstaller.php +++ b/src/ABC/Composer/NonDestructiveArchiveInstallerInstaller.php @@ -51,6 +51,14 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini $this->downloadAndExtractFile($package); } + /** + * {@inheritDoc} + */ + public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) { + if ($this->alwaysInstall($package)) return false; + return parent::isInstalled($repo, $package); + } + /** * {@inheritDoc} */ @@ -66,6 +74,13 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa $this->downloadAndExtractFile($package); } + protected function alwaysInstall(PackageInterface $package) { + $p_extra = $package->getExtra(); + return isset($p_extra['always-install']) && strtolower($p_extra['always-install']) == "false" + ? false + : true; + } + /** * Downloads and extracts the package, only if the URL to download has not been downloaded before. * @@ -90,10 +105,6 @@ private function downloadAndExtractFile(PackageInterface $package) { ? strtolower($p_extra['omit-first-directory']) == "true" : false; - $alwaysInstall = isset($p_extra['always-install']) && strtolower($p_extra['always-install']) == "false" - ? false - : true; - $targetDir = isset($p_extra['target-dir']) ? realpath('./' . trim($p_extra['target-dir'], '/')) . '/' : $this->getInstallPath($package); @@ -112,7 +123,7 @@ private function downloadAndExtractFile(PackageInterface $package) { } // Has archive has been downloaded - if (self::getLastDownloadedFileUrl($package) == $url && !$alwaysInstall) return; + if (self::getLastDownloadedFileUrl($package) == $url && !$this->alwaysInstall($package)) return; // SSL Check if (!extension_loaded('openssl') && 0 === strpos($url, 'https:'))