From ece954a7a46515b2b6a083985c48c3ff42d02f1c 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 02:38:47 +0300 Subject: [PATCH 1/4] Update src/Composer/Downloader/ArchiveDownloader.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix for single-file archives, for example http://sourceforge.net/projects/rssphp/files/rssphp/v1/rss_php.v1.zip/download --- src/Composer/Downloader/ArchiveDownloader.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index ed113e0d4..0f7ae0436 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -58,7 +58,13 @@ abstract class ArchiveDownloader extends FileDownloader rename($file, $path . '/' . basename($file)); } } - rmdir($contentDir); + + if(is_file($contentDir)){ + unlink($contentDir); + } + else{ + rmdir($contentDir); + } } } catch (\Exception $e) { // clean up 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 2/4] 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); } } From 03db848b23be3ac71a2874de92d013e6fad1a97e 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:26:06 +0300 Subject: [PATCH 3/4] Update src/Composer/Downloader/ArchiveDownloader.php Fixed single-file archive post-extraction moving --- src/Composer/Downloader/ArchiveDownloader.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index 3bafc4e8c..e28788633 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -48,8 +48,7 @@ abstract class ArchiveDownloader extends FileDownloader $contentDir = $contentDir[0]; if(is_file($contentDir)){ - rename($contentDir, $path . '/' . basename($fileName)); - unlink($contentDir); + rename($contentDir, $path . '/' . basename($contentDir)); } else{ From 274b54c2b5145cb5454596c963015d6184a6d78a 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 11:55:43 +0300 Subject: [PATCH 4/4] Update src/Composer/Downloader/ArchiveDownloader.php Code style fix --- src/Composer/Downloader/ArchiveDownloader.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index e28788633..810bfb6b2 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -47,10 +47,9 @@ abstract class ArchiveDownloader extends FileDownloader if (1 === count($contentDir)) { $contentDir = $contentDir[0]; - if(is_file($contentDir)){ + if (is_file($contentDir)) { rename($contentDir, $path . '/' . basename($contentDir)); - } - else{ + } else { // Rename the content directory to avoid error when moving up // a child folder with the same name