From 7d5ba2d756204ce997c78ff1b28d68f852d8593d Mon Sep 17 00:00:00 2001 From: MattKetmo Date: Thu, 16 Feb 2012 17:26:42 +0100 Subject: [PATCH] [DownloadFile] Renamed wrapper directory after extract This fixes error when the extracted directory (from an archive) contains a folder with the same name. Example: $ mv test/test test mv: test/test and test/test are identical --- src/Composer/Downloader/FileDownloader.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 168705b5a..8ae89c93c 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -111,6 +111,13 @@ abstract class FileDownloader implements DownloaderInterface $contentDir = glob($path . '/*'); 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));