Merge pull request #2253 from owncloud/fixing-windows-file-mapper-master
Fixing windows file mapper master
This commit is contained in:
commit
84d895dc87
|
@ -77,7 +77,9 @@ class Mapper
|
||||||
$result = $query->execute(array($path1.'%'));
|
$result = $query->execute(array($path1.'%'));
|
||||||
$updateQuery = \OC_DB::prepare('UPDATE `*PREFIX*file_map`'
|
$updateQuery = \OC_DB::prepare('UPDATE `*PREFIX*file_map`'
|
||||||
.' SET `logic_path` = ?'
|
.' SET `logic_path` = ?'
|
||||||
.' AND `physic_path` = ?'
|
.' , `logic_path_hash` = ?'
|
||||||
|
.' , `physic_path` = ?'
|
||||||
|
.' , `physic_path_hash` = ?'
|
||||||
.' WHERE `logic_path` = ?');
|
.' WHERE `logic_path` = ?');
|
||||||
while( $row = $result->fetchRow()) {
|
while( $row = $result->fetchRow()) {
|
||||||
$currentLogic = $row['logic_path'];
|
$currentLogic = $row['logic_path'];
|
||||||
|
@ -86,7 +88,7 @@ class Mapper
|
||||||
$newPhysic = $physicPath2.$this->stripRootFolder($currentPhysic, $physicPath1);
|
$newPhysic = $physicPath2.$this->stripRootFolder($currentPhysic, $physicPath1);
|
||||||
if ($path1 !== $currentLogic) {
|
if ($path1 !== $currentLogic) {
|
||||||
try {
|
try {
|
||||||
$updateQuery->execute(array($newLogic, $newPhysic, $currentLogic));
|
$updateQuery->execute(array($newLogic, md5($newLogic), $newPhysic, md5($newPhysic), $currentLogic));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
error_log('Mapper::Copy failed '.$currentLogic.' -> '.$newLogic.'\n'.$e);
|
error_log('Mapper::Copy failed '.$currentLogic.' -> '.$newLogic.'\n'.$e);
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -149,7 +151,7 @@ class Mapper
|
||||||
|
|
||||||
// detect duplicates
|
// detect duplicates
|
||||||
while ($this->resolvePhysicalPath($physicalPath) !== null) {
|
while ($this->resolvePhysicalPath($physicalPath) !== null) {
|
||||||
$physicalPath = $this->slugifyPath($physicalPath, $index++);
|
$physicalPath = $this->slugifyPath($logicPath, $index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert the new path mapping if requested
|
// insert the new path mapping if requested
|
||||||
|
@ -190,7 +192,7 @@ class Mapper
|
||||||
array_push($sluggedElements, $last.'-'.$index);
|
array_push($sluggedElements, $last.'-'.$index);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements);
|
$sluggedPath = $this->unchangedPhysicalRoot.implode('/', $sluggedElements);
|
||||||
return $this->stripLast($sluggedPath);
|
return $this->stripLast($sluggedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +212,7 @@ class Mapper
|
||||||
|
|
||||||
// transliterate
|
// transliterate
|
||||||
if (function_exists('iconv')) {
|
if (function_exists('iconv')) {
|
||||||
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
|
$text = iconv('utf-8', 'us-ascii//TRANSLIT//IGNORE', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// lowercase
|
// lowercase
|
||||||
|
@ -219,10 +221,8 @@ class Mapper
|
||||||
// remove unwanted characters
|
// remove unwanted characters
|
||||||
$text = preg_replace('~[^-\w]+~', '', $text);
|
$text = preg_replace('~[^-\w]+~', '', $text);
|
||||||
|
|
||||||
if (empty($text))
|
if (empty($text)) {
|
||||||
{
|
return uniqid();
|
||||||
// TODO: we better generate a guid in this case
|
|
||||||
return 'n-a';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
|
|
@ -50,7 +50,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logicalFilePath = $this->mapper->physicalToLogic($physicalPath.DIRECTORY_SEPARATOR.$file);
|
$logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
|
||||||
|
|
||||||
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
|
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
|
||||||
$file = $this->stripLeading($file);
|
$file = $this->stripLeading($file);
|
||||||
|
@ -130,7 +130,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
public function file_get_contents($path) {
|
public function file_get_contents($path) {
|
||||||
return file_get_contents($this->buildPath($path));
|
return file_get_contents($this->buildPath($path));
|
||||||
}
|
}
|
||||||
public function file_put_contents($path, $data) {//trigger_error("$path = ".var_export($path, 1));
|
public function file_put_contents($path, $data) {
|
||||||
return file_put_contents($this->buildPath($path), $data);
|
return file_put_contents($this->buildPath($path), $data);
|
||||||
}
|
}
|
||||||
public function unlink($path) {
|
public function unlink($path) {
|
||||||
|
@ -280,7 +280,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
foreach (scandir($physicalDir) as $item) {
|
foreach (scandir($physicalDir) as $item) {
|
||||||
if ($item == '.' || $item == '..')
|
if ($item == '.' || $item == '..')
|
||||||
continue;
|
continue;
|
||||||
$physicalItem = $this->mapper->physicalToLogic($physicalDir.DIRECTORY_SEPARATOR.$item);
|
$physicalItem = $this->mapper->physicalToLogic($physicalDir.'/'.$item);
|
||||||
$item = substr($physicalItem, strlen($physicalDir)+1);
|
$item = substr($physicalItem, strlen($physicalDir)+1);
|
||||||
|
|
||||||
if(strstr(strtolower($item), strtolower($query)) !== false) {
|
if(strstr(strtolower($item), strtolower($query)) !== false) {
|
||||||
|
@ -331,6 +331,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
if(strpos($path, '/') === 0) {
|
if(strpos($path, '/') === 0) {
|
||||||
$path = substr($path, 1);
|
$path = substr($path, 1);
|
||||||
}
|
}
|
||||||
|
if(strpos($path, '\\') === 0) {
|
||||||
|
$path = substr($path, 1);
|
||||||
|
}
|
||||||
if ($path === false) {
|
if ($path === false) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
require_once 'archive.php';
|
require_once 'archive.php';
|
||||||
|
|
||||||
|
if (!OC_Util::runningOnWindows()) {
|
||||||
class Test_Archive_TAR extends Test_Archive {
|
class Test_Archive_TAR extends Test_Archive {
|
||||||
protected function getExisting() {
|
protected function getExisting() {
|
||||||
$dir = OC::$SERVERROOT . '/tests/data';
|
$dir = OC::$SERVERROOT . '/tests/data';
|
||||||
|
@ -18,3 +19,4 @@ class Test_Archive_TAR extends Test_Archive {
|
||||||
return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
|
return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
require_once 'archive.php';
|
require_once 'archive.php';
|
||||||
|
|
||||||
|
if (!OC_Util::runningOnWindows()) {
|
||||||
class Test_Archive_ZIP extends Test_Archive {
|
class Test_Archive_ZIP extends Test_Archive {
|
||||||
protected function getExisting() {
|
protected function getExisting() {
|
||||||
$dir = OC::$SERVERROOT . '/tests/data';
|
$dir = OC::$SERVERROOT . '/tests/data';
|
||||||
|
@ -18,3 +19,4 @@ class Test_Archive_ZIP extends Test_Archive {
|
||||||
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
|
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -224,8 +224,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchInSubFolder() {
|
public function testSearchInSubFolder() {
|
||||||
$this->instance->mkdir('sub')
|
$this->instance->mkdir('sub');
|
||||||
;
|
|
||||||
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
|
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||||
$this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r'));
|
$this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r'));
|
||||||
$pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png';
|
$pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png';
|
||||||
|
|
Loading…
Reference in New Issue