]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixing various filesystem/storage unit tests on windows
authorThomas Mueller <thomas.mueller@tmit.eu>
Tue, 12 Mar 2013 14:30:10 +0000 (15:30 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Tue, 12 Mar 2013 14:30:10 +0000 (15:30 +0100)
fixing copy operation on mapper

lib/files/mapper.php
lib/files/storage/mappedlocal.php
tests/lib/files/storage/storage.php

index d65726d68deb1e8882e86828941547333c633218..179e28e5e765a8f385310df10d74e1aa2c1dd3e7 100644 (file)
@@ -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;
@@ -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);
        }
 
index 434c10bcbf7ae192cf8f631c100a9b74cf344aca..ba3fcdc5c9e5bee3368c0423a6b1cdd370e16429 100644 (file)
@@ -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 '';
                }
index f78f66d8b8ad1345fa0a62141a8fadee0466bb16..3d68efea5fc78c5358636d1996a9121cb5cc6c4f 100644 (file)
@@ -224,8 +224,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
        }
 
        public function testSearchInSubFolder() {
-               $this->instance->mkdir('sub')
-               ;
+               $this->instance->mkdir('sub');
                $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
                $this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r'));
                $pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png';