diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-18 11:39:04 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-18 11:39:04 +0100 |
commit | 2675290325dc6a67f6719febe5ed0a546bd7a32a (patch) | |
tree | 4bb9a7f1b3de7960e98a4a51e76672eca7c62ca3 /lib/files | |
parent | 4b80466880b4e2daf25e38d621a0ebac608d335d (diff) | |
parent | 3b9796bfcce38e6e4138ffc68f5a2ff6e34492a0 (diff) | |
download | nextcloud-server-2675290325dc6a67f6719febe5ed0a546bd7a32a.tar.gz nextcloud-server-2675290325dc6a67f6719febe5ed0a546bd7a32a.zip |
Merge branch 'master' into master-sqlserver
Diffstat (limited to 'lib/files')
-rw-r--r-- | lib/files/mapper.php | 24 | ||||
-rw-r--r-- | lib/files/storage/mappedlocal.php | 6 |
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/files/mapper.php b/lib/files/mapper.php index cd163dcbfcd..520fadbd8c6 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -7,6 +7,12 @@ namespace OC\Files; */ class Mapper { + private $unchangedPhysicalRoot; + + public function __construct($rootDir) { + $this->unchangedPhysicalRoot = $rootDir; + } + /** * @param string $logicPath * @param bool $create indicates if the generated physical name shall be stored in the database or not @@ -23,7 +29,7 @@ class Mapper /** * @param string $physicalPath - * @return string|null + * @return string */ public function physicalToLogic($physicalPath) { $logicPath = $this->resolvePhysicalPath($physicalPath); @@ -39,6 +45,7 @@ class Mapper * @param string $path * @param bool $isLogicPath indicates if $path is logical or physical * @param $recursive + * @return void */ public function removePath($path, $isLogicPath, $recursive) { if ($recursive) { @@ -159,14 +166,11 @@ class Mapper } private function slugifyPath($path, $index=null) { + $path = $this->stripRootFolder($path, $this->unchangedPhysicalRoot); + $pathElements = explode('/', $path); $sluggedElements = array(); - // skip slugging the drive letter on windows - TODO: test if local path - if (\OC_Util::runningOnWindows()) { - $sluggedElements[]= $pathElements[0]; - array_shift($pathElements); - } foreach ($pathElements as $pathElement) { // remove empty elements if (empty($pathElement)) { @@ -186,12 +190,8 @@ class Mapper array_push($sluggedElements, $last.'-'.$index); } - // on non-windows systems add the leading / if necessary - if (!\OC_Util::runningOnWindows() and $path[0] === '/') { - return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $sluggedElements); - } - - return implode(DIRECTORY_SEPARATOR, $sluggedElements); + $sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements); + return $this->stripLast($sluggedPath); } /** diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index e707f71d71c..434c10bcbf7 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -20,7 +20,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ $this->datadir.='/'; } - $this->mapper= new \OC\Files\Mapper(); + $this->mapper= new \OC\Files\Mapper($this->datadir); } public function __destruct() { if (defined('PHPUNIT_RUN')) { @@ -274,7 +274,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ return $this->buildPath($path); } - protected function searchInDir($query, $dir='', $isLogicPath=true) { + protected function searchInDir($query, $dir='') { $files=array(); $physicalDir = $this->buildPath($dir); foreach (scandir($physicalDir) as $item) { @@ -287,7 +287,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ $files[]=$dir.'/'.$item; } if(is_dir($physicalItem)) { - $files=array_merge($files, $this->searchInDir($query, $physicalItem, false)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } return $files; |