Skip to content

Commit

Permalink
Merge remote-tracking branch 'tot-ra/patch-2'
Browse files Browse the repository at this point in the history
Conflicts:
	src/Composer/Downloader/ArchiveDownloader.php
  • Loading branch information
Seldaek committed Aug 11, 2012
2 parents fe15c6a + 274b54c commit ebc0f88
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/Composer/Downloader/ArchiveDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ public function download(PackageInterface $package, $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());
$this->filesystem->rename($contentDir, $temporaryName);
$contentDir = $temporaryName;
if (is_file($contentDir)) {
$this->filesystem->rename($contentDir, $path . '/' . basename($contentDir));
} else {
// Rename the content directory to avoid error when moving up
// a child folder with the same name
$temporaryName = md5(time().rand());
$this->filesystem->rename($contentDir, $temporaryName);
$contentDir = $temporaryName;

foreach (array_merge(glob($contentDir . '/.*'), glob($contentDir . '/*')) as $file) {
if (trim(basename($file), '.')) {
$this->filesystem->rename($file, $path . '/' . basename($file));
foreach (array_merge(glob($contentDir . '/.*'), glob($contentDir . '/*')) as $file) {
if (trim(basename($file), '.')) {
$this->filesystem->rename($file, $path . '/' . basename($file));
}
}

rmdir($contentDir);
}
rmdir($contentDir);
}
} catch (\Exception $e) {
// clean up
Expand Down

0 comments on commit ebc0f88

Please sign in to comment.