renamed listFiles() to getFolderContent(). fixed comment: the method doesn't return a "list of files in a directory, including dotfiles", it returns a "list of files and folders, excluding dotfiles". switched from !is_file() to is_dir() check.
parent
05d9912f97
commit
01968efa6f
|
@ -49,12 +49,11 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
|
|
||||||
unlink($fileName);
|
unlink($fileName);
|
||||||
|
|
||||||
// get file list
|
$contentDir = $this->getFolderContent($temporaryDir);
|
||||||
$contentDir = $this->listFiles($temporaryDir);
|
|
||||||
|
|
||||||
// only one dir in the archive, extract its contents out of it
|
// only one dir in the archive, extract its contents out of it
|
||||||
if (1 === count($contentDir) && !is_file($contentDir[0])) {
|
if (1 === count($contentDir) && is_dir($contentDir[0])) {
|
||||||
$contentDir = $this->listFiles($contentDir[0]);
|
$contentDir = $this->getFolderContent($contentDir[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move files back out of the temp dir
|
// move files back out of the temp dir
|
||||||
|
@ -128,9 +127,11 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
abstract protected function extract($file, $path);
|
abstract protected function extract($file, $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of files in a directory including dotfiles
|
* Returns the folder content, excluding dotfiles
|
||||||
|
*
|
||||||
|
* @param string $dir Directory
|
||||||
*/
|
*/
|
||||||
private function listFiles($dir)
|
private function getFolderContent($dir)
|
||||||
{
|
{
|
||||||
$files = array_merge(glob($dir . '/.*') ?: array(), glob($dir . '/*') ?: array());
|
$files = array_merge(glob($dir . '/.*') ?: array(), glob($dir . '/*') ?: array());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue