Merge pull request #1618 from owncloud/mapped-storage-unit-testing-linux-master

Mapped storage unit testing linux master
This commit is contained in:
Lukas Reschke 2013-02-12 22:58:37 -08:00
commit 06bba59249
4 changed files with 62 additions and 3 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

@ -9,7 +9,9 @@
namespace OC\Files\Storage;
if (\OC_Util::runningOnWindows()) {
require_once 'mappedlocal.php';
class Local extends MappedLocal {
}
} else {
/**

View File

@ -10,7 +10,7 @@ namespace OC\Files\Storage;
/**
* for local filestore, we only have to map the paths
*/
class Local extends \OC\Files\Storage\Common{
class MappedLocal extends \OC\Files\Storage\Common{
protected $datadir;
private $mapper;
@ -329,6 +329,9 @@ class Local extends \OC\Files\Storage\Common{
if(strpos($path, '/') === 0) {
$path = substr($path, 1);
}
if ($path === false) {
return '';
}
return $path;
}

View File

@ -0,0 +1,40 @@
<?php
/**
* ownCloud
*
* @author Robin Appelman
* @copyright 2012 Robin Appelman icewind@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
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Test\Files\Storage;
class MappedLocal extends Storage {
/**
* @var string tmpDir
*/
private $tmpDir;
public function setUp() {
$this->tmpDir=\OC_Helper::tmpFolder();
$this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir));
}
public function tearDown() {
\OC_Helper::rmdirr($this->tmpDir);
unset($this->instance);
}
}