1
0
Fork 0

Merge pull request #303 from MattKetmo/directory_inception

[BUG] Fix error when moving up a directory content
pull/306/head
Jordi Boggiano 2012-02-16 11:45:37 -08:00
commit 26f2b9e93f
1 changed files with 7 additions and 0 deletions

View File

@ -111,6 +111,13 @@ abstract class FileDownloader implements DownloaderInterface
$contentDir = glob($path . '/*'); $contentDir = glob($path . '/*');
if (1 === count($contentDir)) { if (1 === count($contentDir)) {
$contentDir = $contentDir[0]; $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) { foreach (array_merge(glob($contentDir . '/.*'), glob($contentDir . '/*')) as $file) {
if (trim(basename($file), '.')) { if (trim(basename($file), '.')) {
rename($file, $path . '/' . basename($file)); rename($file, $path . '/' . basename($file));