diff options
Diffstat (limited to 'lib/files')
-rw-r--r-- | lib/files/cache/cache.php | 15 | ||||
-rw-r--r-- | lib/files/cache/permissions.php | 11 | ||||
-rw-r--r-- | lib/files/cache/upgrade.php | 3 | ||||
-rw-r--r-- | lib/files/filesystem.php | 37 | ||||
-rw-r--r-- | lib/files/mapper.php | 30 | ||||
-rw-r--r-- | lib/files/mount.php | 6 | ||||
-rw-r--r-- | lib/files/storage/common.php | 77 | ||||
-rw-r--r-- | lib/files/storage/local.php | 14 | ||||
-rw-r--r-- | lib/files/storage/mappedlocal.php | 21 | ||||
-rw-r--r-- | lib/files/view.php | 16 |
10 files changed, 150 insertions, 80 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 38b35c69def..3652dc7cf23 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -48,6 +48,9 @@ class Cache { } else { $this->storageId = $storage; } + if (strlen($this->storageId) > 64) { + $this->storageId = md5($this->storageId); + } $query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?'); $result = $query->execute(array($this->storageId)); @@ -198,7 +201,8 @@ class Cache { $params[] = $this->numericId; $valuesPlaceholder = array_fill(0, count($queryParts), '?'); - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ') VALUES(' . implode(', ', $valuesPlaceholder) . ')'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ')' + . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); $query->execute($params); return (int)\OC_DB::insertid('*PREFIX*filecache'); @@ -215,7 +219,8 @@ class Cache { list($queryParts, $params) = $this->buildParts($data); $params[] = $id; - $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? WHERE fileid = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=?' + . ' WHERE fileid = ?'); $query->execute($params); } @@ -332,7 +337,8 @@ class Cache { $query->execute(array($targetPath, md5($targetPath), $child['fileid'])); } - $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =? WHERE `fileid` = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =?' + . ' WHERE `fileid` = ?'); $query->execute(array($target, md5($target), $newParentId, $sourceId)); } @@ -492,7 +498,8 @@ class Cache { * @return string|bool the path of the folder or false when no folder matched */ public function getIncomplete() { - $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); + $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache`' + . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); $query->execute(array($this->numericId)); if ($row = $query->fetchRow()) { return $row['path']; diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php index d0968337f02..e1735831b94 100644 --- a/lib/files/cache/permissions.php +++ b/lib/files/cache/permissions.php @@ -18,7 +18,7 @@ class Permissions { * @param \OC\Files\Storage\Storage|string $storage */ public function __construct($storage){ - if($storage instanceof \OC\Files\Storage\Storage){ + if($storage instanceof \OC\Files\Storage\Storage) { $this->storageId = $storage->getId(); }else{ $this->storageId = $storage; @@ -51,9 +51,11 @@ class Permissions { */ public function set($fileId, $user, $permissions) { if (self::get($fileId, $user) !== -1) { - $query = \OC_DB::prepare('UPDATE `*PREFIX*permissions` SET `permissions` = ? WHERE `user` = ? AND `fileid` = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*permissions` SET `permissions` = ?' + .' WHERE `user` = ? AND `fileid` = ?'); } else { - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*permissions`(`permissions`, `user`, `fileid`) VALUES(?, ?,? )'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*permissions`(`permissions`, `user`, `fileid`)' + .' VALUES(?, ?,? )'); } $query->execute(array($permissions, $user, $fileId)); } @@ -73,7 +75,8 @@ class Permissions { $params[] = $user; $inPart = implode(', ', array_fill(0, count($fileIds), '?')); - $query = \OC_DB::prepare('SELECT `fileid`, `permissions` FROM `*PREFIX*permissions` WHERE `fileid` IN (' . $inPart . ') AND `user` = ?'); + $query = \OC_DB::prepare('SELECT `fileid`, `permissions` FROM `*PREFIX*permissions`' + .' WHERE `fileid` IN (' . $inPart . ') AND `user` = ?'); $result = $query->execute($params); $filePermissions = array(); while ($row = $result->fetchRow()) { diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php index eb8c7297c3e..1fe4c584686 100644 --- a/lib/files/cache/upgrade.php +++ b/lib/files/cache/upgrade.php @@ -69,7 +69,8 @@ class Upgrade { ( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); - $insertQuery->execute(array($data['id'], $data['storage'], $data['path'], $data['path_hash'], $data['parent'], $data['name'], + $insertQuery->execute(array($data['id'], $data['storage'], + $data['path'], $data['path_hash'], $data['parent'], $data['name'], $data['mimetype'], $data['mimepart'], $data['size'], $data['mtime'], $data['encrypted'])); } } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index a0c3c4b9b75..875a9d6c5ee 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -29,6 +29,8 @@ namespace OC\Files; +const FREE_SPACE_UNKNOWN = -2; + class Filesystem { public static $loaded = false; /** @@ -135,7 +137,9 @@ class Filesystem { /** * get the mountpoint of the storage object for a path - ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account + * ( note: because a storage is not always mounted inside the fakeroot, the + * returned mountpoint is relative to the absolute root of the filesystem + * and doesn't take the chroot into account ) * * @param string $path * @return string @@ -213,9 +217,15 @@ class Filesystem { if ($user == '') { $user = \OC_User::getUser(); } + $parser = new \OC\ArrayParser(); + // Load system mount points - if (is_file(\OC::$SERVERROOT . '/config/mount.php')) { - $mountConfig = include 'config/mount.php'; + if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) { + if(is_file(\OC::$SERVERROOT . '/config/mount.json')){ + $mountConfig = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mount.json'), true); + }elseif(is_file(\OC::$SERVERROOT . '/config/mount.php')){ + $mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php')); + } if (isset($mountConfig['global'])) { foreach ($mountConfig['global'] as $mountPoint => $options) { self::mount($options['class'], $options['options'], $mountPoint); @@ -251,8 +261,12 @@ class Filesystem { // Load personal mount points $root = \OC_User::getHome($user); self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); - if (is_file($root . '/mount.php')) { - $mountConfig = include $root . '/mount.php'; + if (is_file($root . '/mount.php') or is_file($root . '/mount.json')) { + if (is_file($root . '/mount.json')){ + $mountConfig = json_decode(file_get_contents($root . '/mount.json'), true); + } elseif (is_file($root . '/mount.php')){ + $mountConfig = $parser->parsePHP(file_get_contents($root . '/mount.php')); + } if (isset($mountConfig['user'][$user])) { foreach ($mountConfig['user'][$user] as $mountPoint => $options) { self::mount($options['class'], $options['options'], $mountPoint); @@ -318,7 +332,8 @@ class Filesystem { /** * return the path to a local version of the file - * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed + * we need this because we can't know if a file is stored local or not from + * outside the filestorage and for some purposes a local file is needed * * @param string $path * @return string @@ -610,11 +625,11 @@ class Filesystem { } /** - * Get the owner for a file or folder - * - * @param string $path - * @return string - */ + * Get the owner for a file or folder + * + * @param string $path + * @return string + */ public static function getOwner($path) { return self::$defaultInstance->getOwner($path); } diff --git a/lib/files/mapper.php b/lib/files/mapper.php index 71b665e49bb..520fadbd8c6 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -7,6 +7,12 @@ namespace OC\Files; */ class Mapper { + private $unchangedPhysicalRoot; + + public function __construct($rootDir) { + $this->unchangedPhysicalRoot = $rootDir; + } + /** * @param string $logicPath * @param bool $create indicates if the generated physical name shall be stored in the database or not @@ -23,7 +29,7 @@ class Mapper /** * @param string $physicalPath - * @return string|null + * @return string */ public function physicalToLogic($physicalPath) { $logicPath = $this->resolvePhysicalPath($physicalPath); @@ -39,6 +45,7 @@ class Mapper * @param string $path * @param bool $isLogicPath indicates if $path is logical or physical * @param $recursive + * @return void */ public function removePath($path, $isLogicPath, $recursive) { if ($recursive) { @@ -107,7 +114,7 @@ class Mapper private function stripLast($path) { if (substr($path, -1) == '/') { - $path = substr_replace($path ,'',-1); + $path = substr_replace($path, '', -1); } return $path; } @@ -117,6 +124,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']; } @@ -156,15 +166,17 @@ class Mapper } private function slugifyPath($path, $index=null) { + $path = $this->stripRootFolder($path, $this->unchangedPhysicalRoot); + $pathElements = explode('/', $path); $sluggedElements = array(); - // skip slugging the drive letter on windows - TODO: test if local path - if (strpos(strtolower(php_uname('s')), 'win') !== false) { - $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,7 +189,9 @@ class Mapper array_pop($sluggedElements); array_push($sluggedElements, $last.'-'.$index); } - return implode(DIRECTORY_SEPARATOR, $sluggedElements); + + $sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements); + return $this->stripLast($sluggedPath); } /** diff --git a/lib/files/mount.php b/lib/files/mount.php index 74ee483b1be..6e99d8eabb4 100644 --- a/lib/files/mount.php +++ b/lib/files/mount.php @@ -93,6 +93,9 @@ class Mount { $this->storage = $this->createStorage(); } $this->storageId = $this->storage->getId(); + if (strlen($this->storageId) > 64) { + $this->storageId = md5($this->storageId); + } } return $this->storageId; } @@ -177,6 +180,9 @@ class Mount { * @return \OC\Files\Storage\Storage[] */ public static function findById($id) { + if (strlen($id) > 64) { + $id = md5($id); + } $result = array(); foreach (self::$mounts as $mount) { if ($mount->getStorageId() === $id) { diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 89d603917eb..f23dcf0d4eb 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -51,19 +51,19 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function getPermissions($path){ $permissions = 0; - if($this->isCreatable($path)){ + if($this->isCreatable($path)) { $permissions |= \OCP\PERMISSION_CREATE; } - if($this->isReadable($path)){ + if($this->isReadable($path)) { $permissions |= \OCP\PERMISSION_READ; } - if($this->isUpdatable($path)){ + if($this->isUpdatable($path)) { $permissions |= \OCP\PERMISSION_UPDATE; } - if($this->isDeletable($path)){ + if($this->isDeletable($path)) { $permissions |= \OCP\PERMISSION_DELETE; } - if($this->isSharable($path)){ + if($this->isSharable($path)) { $permissions |= \OCP\PERMISSION_SHARE; } return $permissions; @@ -83,21 +83,21 @@ abstract class Common implements \OC\Files\Storage\Storage { } return fread($handle, $size); } - public function file_put_contents($path,$data) { + public function file_put_contents($path, $data) { $handle = $this->fopen($path, "w"); return fwrite($handle, $data); } - public function rename($path1,$path2) { - if($this->copy($path1,$path2)) { + public function rename($path1, $path2) { + if($this->copy($path1, $path2)) { return $this->unlink($path1); }else{ return false; } } - public function copy($path1,$path2) { - $source=$this->fopen($path1,'r'); - $target=$this->fopen($path2,'w'); - $count=\OC_Helper::streamCopy($source,$target); + public function copy($path1, $path2) { + $source=$this->fopen($path1, 'r'); + $target=$this->fopen($path2, 'w'); + $count=\OC_Helper::streamCopy($source, $target); return $count>0; } @@ -111,9 +111,10 @@ abstract class Common implements \OC\Files\Storage\Storage { * deleted together with its contents. To avoid this set $empty to true */ public function deleteAll( $directory, $empty = false ) { - $directory = trim($directory,'/'); + $directory = trim($directory, '/'); - if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { + if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) + || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { return false; } elseif( !$this->isReadable( \OCP\USER::getUser() . '/' . $directory ) ) { return false; @@ -132,7 +133,7 @@ abstract class Common implements \OC\Files\Storage\Storage { //$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV if ( $empty == false ) { if ( !$this->rmdir( $directory ) ) { - return false; + return false; } } return true; @@ -146,25 +147,25 @@ abstract class Common implements \OC\Files\Storage\Storage { if($this->is_dir($path)) { return 'httpd/unix-directory'; } - $source=$this->fopen($path,'r'); + $source=$this->fopen($path, 'r'); if(!$source) { return false; } - $head=fread($source,8192);//8kb should suffice to determine a mimetype - if($pos=strrpos($path,'.')) { - $extension=substr($path,$pos); + $head=fread($source, 8192);//8kb should suffice to determine a mimetype + if($pos=strrpos($path, '.')) { + $extension=substr($path, $pos); }else{ $extension=''; } $tmpFile=\OC_Helper::tmpFile($extension); - file_put_contents($tmpFile,$head); + file_put_contents($tmpFile, $head); $mime=\OC_Helper::getMimeType($tmpFile); unlink($tmpFile); return $mime; } - public function hash($type,$path,$raw = false) { + public function hash($type, $path, $raw = false) { $tmpFile=$this->getLocalFile($path); - $hash=hash($type,$tmpFile,$raw); + $hash=hash($type, $tmpFile, $raw); unlink($tmpFile); return $hash; } @@ -175,42 +176,42 @@ abstract class Common implements \OC\Files\Storage\Storage { return $this->toTmpFile($path); } private function toTmpFile($path) {//no longer in the storage api, still useful here - $source=$this->fopen($path,'r'); + $source=$this->fopen($path, 'r'); if(!$source) { return false; } - if($pos=strrpos($path,'.')) { - $extension=substr($path,$pos); + if($pos=strrpos($path, '.')) { + $extension=substr($path, $pos); }else{ $extension=''; } $tmpFile=\OC_Helper::tmpFile($extension); - $target=fopen($tmpFile,'w'); - \OC_Helper::streamCopy($source,$target); + $target=fopen($tmpFile, 'w'); + \OC_Helper::streamCopy($source, $target); return $tmpFile; } public function getLocalFolder($path) { $baseDir=\OC_Helper::tmpFolder(); - $this->addLocalFolder($path,$baseDir); + $this->addLocalFolder($path, $baseDir); return $baseDir; } - private function addLocalFolder($path,$target) { + private function addLocalFolder($path, $target) { if($dh=$this->opendir($path)) { while($file=readdir($dh)) { if($file!=='.' and $file!=='..') { if($this->is_dir($path.'/'.$file)) { mkdir($target.'/'.$file); - $this->addLocalFolder($path.'/'.$file,$target.'/'.$file); + $this->addLocalFolder($path.'/'.$file, $target.'/'.$file); }else{ $tmp=$this->toTmpFile($path.'/'.$file); - rename($tmp,$target.'/'.$file); + rename($tmp, $target.'/'.$file); } } } } } - protected function searchInDir($query,$dir='') { + protected function searchInDir($query, $dir='') { $files=array(); $dh=$this->opendir($dir); if($dh) { @@ -220,7 +221,7 @@ abstract class Common implements \OC\Files\Storage\Storage { $files[]=$dir.'/'.$item; } if($this->is_dir($dir.'/'.$item)) { - $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } } @@ -233,7 +234,7 @@ abstract class Common implements \OC\Files\Storage\Storage { * @param int $time * @return bool */ - public function hasUpdated($path,$time) { + public function hasUpdated($path, $time) { return $this->filemtime($path)>$time; } @@ -308,4 +309,12 @@ abstract class Common implements \OC\Files\Storage\Storage { return false; } + /** + * get the free space in the storage + * @param $path + * return int + */ + public function free_space($path){ + return \OC\Files\FREE_SPACE_UNKNOWN; + } } diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index 9fe01135866..da6597c8057 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -9,7 +9,9 @@ namespace OC\Files\Storage; if (\OC_Util::runningOnWindows()) { - require_once 'mappedlocal.php'; + class Local extends MappedLocal { + + } } else { /** @@ -38,7 +40,7 @@ class Local extends \OC\Files\Storage\Common{ return opendir($this->datadir.$path); } public function is_dir($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return is_dir($this->datadir.$path); @@ -115,11 +117,11 @@ class Local extends \OC\Files\Storage\Common{ } public function rename($path1, $path2) { if (!$this->isUpdatable($path1)) { - \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, \OC_Log::ERROR); return false; } if(! $this->file_exists($path1)) { - \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, \OC_Log::ERROR); return false; } @@ -203,7 +205,9 @@ class Local extends \OC\Files\Storage\Common{ return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); } } else { - \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + \OC_Log::write('core', + 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, + \OC_Log::ERROR); } return 0; diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 80dd79bc41f..434c10bcbf7 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -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; @@ -20,7 +20,7 @@ class Local extends \OC\Files\Storage\Common{ $this->datadir.='/'; } - $this->mapper= new \OC\Files\Mapper(); + $this->mapper= new \OC\Files\Mapper($this->datadir); } public function __destruct() { if (defined('PHPUNIT_RUN')) { @@ -61,7 +61,7 @@ class Local extends \OC\Files\Storage\Common{ return opendir('fakedir://local-win32'.$path); } public function is_dir($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return is_dir($this->buildPath($path)); @@ -138,11 +138,11 @@ class Local extends \OC\Files\Storage\Common{ } public function rename($path1, $path2) { if (!$this->isUpdatable($path1)) { - \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, \OC_Log::ERROR); return false; } if(! $this->file_exists($path1)) { - \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, \OC_Log::ERROR); return false; } @@ -248,7 +248,9 @@ class Local extends \OC\Files\Storage\Common{ return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); } } else { - \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + \OC_Log::write('core', + 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, + \OC_Log::ERROR); } return 0; @@ -272,7 +274,7 @@ class Local extends \OC\Files\Storage\Common{ return $this->buildPath($path); } - protected function searchInDir($query, $dir='', $isLogicPath=true) { + protected function searchInDir($query, $dir='') { $files=array(); $physicalDir = $this->buildPath($dir); foreach (scandir($physicalDir) as $item) { @@ -285,7 +287,7 @@ class Local extends \OC\Files\Storage\Common{ $files[]=$dir.'/'.$item; } if(is_dir($physicalItem)) { - $files=array_merge($files, $this->searchInDir($query, $physicalItem, false)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } return $files; @@ -329,6 +331,9 @@ class Local extends \OC\Files\Storage\Common{ if(strpos($path, '/') === 0) { $path = substr($path, 1); } + if ($path === false) { + return ''; + } return $path; } diff --git a/lib/files/view.php b/lib/files/view.php index 1a234228eab..9ac08c98082 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -92,7 +92,9 @@ class View { /** * get the mountpoint of the storage object for a path - ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account + * ( note: because a storage is not always mounted inside the fakeroot, the + * returned mountpoint is relative to the absolute root of the filesystem + * and doesn't take the chroot into account ) * * @param string $path * @return string @@ -113,7 +115,8 @@ class View { /** * return the path to a local version of the file - * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed + * we need this because we can't know if a file is stored local or not from + * outside the filestorage and for some purposes a local file is needed * * @param string $path * @return string @@ -252,7 +255,8 @@ class View { public function file_put_contents($path, $data) { if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); - if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && Filesystem::isValidPath($path)) { + if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) + && Filesystem::isValidPath($path)) { $path = $this->getRelativePath($absolutePath); $exists = $this->file_exists($path); $run = true; @@ -324,7 +328,8 @@ class View { $postFix2 = (substr($path2, -1, 1) === '/') ? '/' : ''; $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); - if (\OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) and Filesystem::isValidPath($path2)) { + if (\OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) + and Filesystem::isValidPath($path2)) { $path1 = $this->getRelativePath($absolutePath1); $path2 = $this->getRelativePath($absolutePath2); @@ -776,7 +781,8 @@ class View { $rootEntry = $subCache->get(''); if ($rootEntry) { $relativePath = trim(substr($mountPoint, $dirLength), '/'); - if ($pos = strpos($relativePath, '/')) { //mountpoint inside subfolder add size to the correct folder + if ($pos = strpos($relativePath, '/')) { + //mountpoint inside subfolder add size to the correct folder $entryName = substr($relativePath, 0, $pos); foreach ($files as &$entry) { if ($entry['name'] === $entryName) { |