Merge pull request #6898 from owncloud/encryption_infinite_loop
[encryption] infinite loop on sharing
This commit is contained in:
commit
0daabe5b6a
2 changed files with 30 additions and 45 deletions
|
@ -2,9 +2,10 @@
|
|||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Sam Tuke, Frank Karlitschek
|
||||
* @author Sam Tuke, Frank Karlitschek, Bjoern Schiessle
|
||||
* @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
|
||||
* 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.
|
||||
* @param string $dir relative to the users files folder
|
||||
* @return array with list of files relative to the users files folder
|
||||
*/
|
||||
public function getAllFiles($dir) {
|
||||
|
||||
$result = array();
|
||||
$dirList = array($dir);
|
||||
|
||||
while ($dirList) {
|
||||
$dir = array_pop($dirList);
|
||||
$content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
|
||||
$this->userFilesDir . '/' . $dir));
|
||||
|
||||
// handling for re shared folders
|
||||
$pathSplit = explode('/', $dir);
|
||||
|
||||
foreach ($content as $c) {
|
||||
|
||||
$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;
|
||||
|
||||
$usersPath = isset($c['usersPath']) ? $c['usersPath'] : $c['path'];
|
||||
if ($c['type'] === 'dir') {
|
||||
|
||||
$result = array_merge($result, $this->getAllFiles($path));
|
||||
|
||||
$dirList[] = substr($usersPath, strlen("files"));
|
||||
} else {
|
||||
|
||||
$result[] = $path;
|
||||
|
||||
$result[] = substr($usersPath, strlen("files"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -127,7 +127,18 @@ class Shared_Cache extends Cache {
|
|||
return $files;
|
||||
} else {
|
||||
if ($cache = $this->getSourceCache($folder)) {
|
||||
return $cache->getFolderContents($this->files[$folder]);
|
||||
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
|
||||
foreach ($sourceFolderContent as $key => $c) {
|
||||
$ownerPathParts = explode('/', \OC_Filesystem::normalizePath($c['path']));
|
||||
$userPathParts = explode('/', \OC_Filesystem::normalizePath($folder));
|
||||
$usersPath = 'files/Shared/'.$userPathParts[1];
|
||||
foreach (array_slice($ownerPathParts, 3) as $part) {
|
||||
$usersPath .= '/'.$part;
|
||||
}
|
||||
$sourceFolderContent[$key]['usersPath'] = $usersPath;
|
||||
}
|
||||
|
||||
return $sourceFolderContent;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue