diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-11 13:53:10 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-11 13:53:10 +0100 |
commit | 92e6409f4008d21c8507310d7b6ce0f64fc29b71 (patch) | |
tree | 02eb2b47f614073ba7872f3ea0e076e829edf202 /lib/files | |
parent | f223ab796b8b6da796321502e8eeffed81973629 (diff) | |
download | nextcloud-server-92e6409f4008d21c8507310d7b6ce0f64fc29b71.tar.gz nextcloud-server-92e6409f4008d21c8507310d7b6ce0f64fc29b71.zip |
fixing mappedlocal storage to work on non-windows as well
this allows us to run unit tests on linux - necessary to enable easy regression testing
Diffstat (limited to 'lib/files')
-rw-r--r-- | lib/files/mapper.php | 16 | ||||
-rw-r--r-- | lib/files/storage/mappedlocal.php | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/files/mapper.php b/lib/files/mapper.php index 71b665e49bb..2d29a8532b6 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -117,6 +117,9 @@ class Mapper $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `logic_path_hash` = ?'); $result = $query->execute(array(md5($logicPath))); $result = $result->fetchRow(); + if ($result === false) { + return null; + } return $result['physic_path']; } @@ -160,11 +163,16 @@ class Mapper $sluggedElements = array(); // skip slugging the drive letter on windows - TODO: test if local path - if (strpos(strtolower(php_uname('s')), 'win') !== false) { + if (\OC_Util::runningOnWindows()) { $sluggedElements[]= $pathElements[0]; array_shift($pathElements); } foreach ($pathElements as $pathElement) { + // remove empty elements + if (empty($pathElement)) { + continue; + } + // TODO: remove file ext before slugify on last element $sluggedElements[] = self::slugify($pathElement); } @@ -177,6 +185,12 @@ class Mapper array_pop($sluggedElements); 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); } diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 411b053737a..218465d8eef 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -329,6 +329,9 @@ class MappedLocal extends \OC\Files\Storage\Common{ if(strpos($path, '/') === 0) { $path = substr($path, 1); } + if ($path === false) { + return ''; + } return $path; } |