summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-03-12 11:48:29 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-03-12 11:48:29 -0700
commit84d895dc87fc5e4c91ee3a31bd6e114e50350db7 (patch)
tree56810a0d754ad83db48d73bbcf2b7844b22f118b /lib
parent68a7b53e031d8a7ece5f73fb8f7821d18ea037b8 (diff)
parenta05820c6594aa3ea6f2394e8d75117d339f06ed3 (diff)
downloadnextcloud-server-84d895dc87fc5e4c91ee3a31bd6e114e50350db7.tar.gz
nextcloud-server-84d895dc87fc5e4c91ee3a31bd6e114e50350db7.zip
Merge pull request #2253 from owncloud/fixing-windows-file-mapper-master
Fixing windows file mapper master
Diffstat (limited to 'lib')
-rw-r--r--lib/files/mapper.php18
-rw-r--r--lib/files/storage/mappedlocal.php9
2 files changed, 15 insertions, 12 deletions
diff --git a/lib/files/mapper.php b/lib/files/mapper.php
index 520fadbd8c6..179e28e5e76 100644
--- a/lib/files/mapper.php
+++ b/lib/files/mapper.php
@@ -77,7 +77,9 @@ class Mapper
$result = $query->execute(array($path1.'%'));
$updateQuery = \OC_DB::prepare('UPDATE `*PREFIX*file_map`'
.' SET `logic_path` = ?'
- .' AND `physic_path` = ?'
+ .' , `logic_path_hash` = ?'
+ .' , `physic_path` = ?'
+ .' , `physic_path_hash` = ?'
.' WHERE `logic_path` = ?');
while( $row = $result->fetchRow()) {
$currentLogic = $row['logic_path'];
@@ -86,7 +88,7 @@ class Mapper
$newPhysic = $physicPath2.$this->stripRootFolder($currentPhysic, $physicPath1);
if ($path1 !== $currentLogic) {
try {
- $updateQuery->execute(array($newLogic, $newPhysic, $currentLogic));
+ $updateQuery->execute(array($newLogic, md5($newLogic), $newPhysic, md5($newPhysic), $currentLogic));
} catch (\Exception $e) {
error_log('Mapper::Copy failed '.$currentLogic.' -> '.$newLogic.'\n'.$e);
throw $e;
@@ -149,7 +151,7 @@ class Mapper
// detect duplicates
while ($this->resolvePhysicalPath($physicalPath) !== null) {
- $physicalPath = $this->slugifyPath($physicalPath, $index++);
+ $physicalPath = $this->slugifyPath($logicPath, $index++);
}
// insert the new path mapping if requested
@@ -190,7 +192,7 @@ class Mapper
array_push($sluggedElements, $last.'-'.$index);
}
- $sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements);
+ $sluggedPath = $this->unchangedPhysicalRoot.implode('/', $sluggedElements);
return $this->stripLast($sluggedPath);
}
@@ -210,7 +212,7 @@ class Mapper
// transliterate
if (function_exists('iconv')) {
- $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
+ $text = iconv('utf-8', 'us-ascii//TRANSLIT//IGNORE', $text);
}
// lowercase
@@ -219,10 +221,8 @@ class Mapper
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
- if (empty($text))
- {
- // TODO: we better generate a guid in this case
- return 'n-a';
+ if (empty($text)) {
+ return uniqid();
}
return $text;
diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php
index 434c10bcbf7..ba3fcdc5c9e 100644
--- a/lib/files/storage/mappedlocal.php
+++ b/lib/files/storage/mappedlocal.php
@@ -50,7 +50,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
continue;
}
- $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.DIRECTORY_SEPARATOR.$file);
+ $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
$file = $this->stripLeading($file);
@@ -130,7 +130,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
public function file_get_contents($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);
}
public function unlink($path) {
@@ -280,7 +280,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
foreach (scandir($physicalDir) as $item) {
if ($item == '.' || $item == '..')
continue;
- $physicalItem = $this->mapper->physicalToLogic($physicalDir.DIRECTORY_SEPARATOR.$item);
+ $physicalItem = $this->mapper->physicalToLogic($physicalDir.'/'.$item);
$item = substr($physicalItem, strlen($physicalDir)+1);
if(strstr(strtolower($item), strtolower($query)) !== false) {
@@ -331,6 +331,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
if(strpos($path, '/') === 0) {
$path = substr($path, 1);
}
+ if(strpos($path, '\\') === 0) {
+ $path = substr($path, 1);
+ }
if ($path === false) {
return '';
}