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
This commit is contained in:
Thomas Mueller 2013-02-11 13:53:10 +01:00
parent f223ab796b
commit 92e6409f40
2 changed files with 18 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;
}