From 091b2e86db6bfc9d6c07eed0b6b22466c52995be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9A=D1=83=D1=80=D0=B0?= =?UTF-8?q?=D0=BF=D0=BE=D0=B2?= Date: Sun, 5 Aug 2012 03:15:55 +0300 Subject: [PATCH] Update src/Composer/Downloader/ArchiveDownloader.php Fix to single-file archive --- src/Composer/Downloader/ArchiveDownloader.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index 0f7ae0436..3bafc4e8c 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -47,22 +47,25 @@ abstract class ArchiveDownloader extends FileDownloader if (1 === count($contentDir)) { $contentDir = $contentDir[0]; - // Rename the content directory to avoid error when moving up - // a child folder with the same name - $temporaryName = md5(time().rand()); - rename($contentDir, $temporaryName); - $contentDir = $temporaryName; - - foreach (array_merge(glob($contentDir . '/.*'), glob($contentDir . '/*')) as $file) { - if (trim(basename($file), '.')) { - rename($file, $path . '/' . basename($file)); - } - } - if(is_file($contentDir)){ + rename($contentDir, $path . '/' . basename($fileName)); unlink($contentDir); } else{ + + // Rename the content directory to avoid error when moving up + // a child folder with the same name + $temporaryName = md5(time().rand()); + rename($contentDir, $temporaryName); + $contentDir = $temporaryName; + + foreach (array_merge(glob($contentDir . '/.*'), glob($contentDir . '/*')) as $file) { + if (trim(basename($file), '.')) { + rename($file, $path . '/' . basename($file)); + } + } + + rmdir($contentDir); } }