Skip to content
Snippets Groups Projects
Commit 92e6409f authored by Thomas Müller's avatar Thomas Müller
Browse files

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
parent f223ab79
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment