|
@@ -175,6 +175,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$this->filesystem->ensureDirectoryExists(dirname($targetDir));
|
|
$this->filesystem->ensureDirectoryExists(dirname($targetDir));
|
|
|
|
|
|
$sources = $this->getAvailableSources($package, $prevPackage);
|
|
$sources = $this->getAvailableSources($package, $prevPackage);
|
|
@@ -244,6 +245,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
if ($downloader) {
|
|
if ($downloader) {
|
|
return $downloader->prepare($type, $package, $targetDir, $prevPackage);
|
|
return $downloader->prepare($type, $package, $targetDir, $prevPackage);
|
|
@@ -262,6 +264,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function install(PackageInterface $package, $targetDir)
|
|
public function install(PackageInterface $package, $targetDir)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
if ($downloader) {
|
|
if ($downloader) {
|
|
return $downloader->install($package, $targetDir);
|
|
return $downloader->install($package, $targetDir);
|
|
@@ -280,6 +283,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
|
|
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$downloader = $this->getDownloaderForPackage($target);
|
|
$downloader = $this->getDownloaderForPackage($target);
|
|
$initialDownloader = $this->getDownloaderForPackage($initial);
|
|
$initialDownloader = $this->getDownloaderForPackage($initial);
|
|
|
|
|
|
@@ -332,6 +336,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function remove(PackageInterface $package, $targetDir)
|
|
public function remove(PackageInterface $package, $targetDir)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
if ($downloader) {
|
|
if ($downloader) {
|
|
return $downloader->remove($package, $targetDir);
|
|
return $downloader->remove($package, $targetDir);
|
|
@@ -350,6 +355,7 @@ class DownloadManager
|
|
*/
|
|
*/
|
|
public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
|
|
{
|
|
{
|
|
|
|
+ $targetDir = $this->normalizeTargetDir($targetDir);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
$downloader = $this->getDownloaderForPackage($package);
|
|
if ($downloader) {
|
|
if ($downloader) {
|
|
return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
|
|
return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
|
|
@@ -422,4 +428,20 @@ class DownloadManager
|
|
|
|
|
|
return $sources;
|
|
return $sources;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Downloaders expect a /path/to/dir without trailing slash
|
|
|
|
+ *
|
|
|
|
+ * If any Installer provides a path with a trailing slash, this can cause bugs so make sure we remove them
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ private function normalizeTargetDir($dir)
|
|
|
|
+ {
|
|
|
|
+ if ($dir === '\\' || $dir === '/') {
|
|
|
|
+ return $dir;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return rtrim($dir, '\\/');
|
|
|
|
+ }
|
|
}
|
|
}
|