fix infinite loop if folder and subfolder has the same name
This commit is contained in:
parent
eaed786eed
commit
b489d6b0af
|
@ -2,9 +2,10 @@
|
||||||
/**
|
/**
|
||||||
* ownCloud
|
* ownCloud
|
||||||
*
|
*
|
||||||
* @author Sam Tuke, Frank Karlitschek
|
* @author Sam Tuke, Frank Karlitschek, Bjoern Schiessle
|
||||||
* @copyright 2012 Sam Tuke <samtuke@owncloud.com>,
|
* @copyright 2012 Sam Tuke <samtuke@owncloud.com>,
|
||||||
* Frank Karlitschek <frank@owncloud.org>
|
* Frank Karlitschek <frank@owncloud.org>,
|
||||||
|
* Bjoern Schiessle <schiessle@owncloud.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
@ -1360,59 +1361,32 @@ class Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief go recursively through a dir and collect all files and sub files.
|
* @brief go recursively through a dir and collect all files and sub files.
|
||||||
* @param string $dir relative to the users files folder
|
* @param string $dir relative to the users files folder
|
||||||
* @return array with list of files relative to the users files folder
|
* @return array with list of files relative to the users files folder
|
||||||
*/
|
*/
|
||||||
public function getAllFiles($dir) {
|
public function getAllFiles($dir) {
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
$dirList = array($dir);
|
||||||
|
|
||||||
|
while ($dirList) {
|
||||||
|
$dir = array_pop($dirList);
|
||||||
$content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
|
$content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
|
||||||
$this->userFilesDir . '/' . $dir));
|
$this->userFilesDir . '/' . $dir));
|
||||||
|
|
||||||
// handling for re shared folders
|
|
||||||
$pathSplit = explode('/', $dir);
|
|
||||||
|
|
||||||
foreach ($content as $c) {
|
foreach ($content as $c) {
|
||||||
|
$usersPath = isset($c['usersPath']) ? $c['usersPath'] : $c['path'];
|
||||||
$sharedPart = $pathSplit[sizeof($pathSplit) - 1];
|
|
||||||
$targetPathSplit = array_reverse(explode('/', $c['path']));
|
|
||||||
|
|
||||||
$path = '';
|
|
||||||
|
|
||||||
// rebuild path
|
|
||||||
foreach ($targetPathSplit as $pathPart) {
|
|
||||||
|
|
||||||
if ($pathPart !== $sharedPart) {
|
|
||||||
|
|
||||||
$path = '/' . $pathPart . $path;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = $dir . $path;
|
|
||||||
|
|
||||||
if ($c['type'] === 'dir') {
|
if ($c['type'] === 'dir') {
|
||||||
|
$dirList[] = substr($usersPath, strlen("files"));
|
||||||
$result = array_merge($result, $this->getAllFiles($path));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$result[] = substr($usersPath, strlen("files"));
|
||||||
$result[] = $path;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue