diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-26 18:08:49 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-26 18:08:49 +0200 |
commit | 2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9 (patch) | |
tree | f25b463c90992764887416c3082098fed6ecac65 /lib | |
parent | 40f95ffdf3edf9ab45c15bd5b9018d7f4d92baa9 (diff) | |
parent | 127796218314c6b1f19ba86f74caa913375aac8d (diff) | |
download | nextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.tar.gz nextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.zip |
fix merge conflicts
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/connector/sabre/directory.php | 2 | ||||
-rw-r--r-- | lib/connector/sabre/principal.php | 4 | ||||
-rw-r--r-- | lib/filecache.php | 15 | ||||
-rw-r--r-- | lib/filesystem.php | 48 | ||||
-rw-r--r-- | lib/filesystemview.php | 19 | ||||
-rwxr-xr-x | lib/helper.php | 12 | ||||
-rw-r--r-- | lib/vobject.php | 6 |
8 files changed, 92 insertions, 16 deletions
diff --git a/lib/base.php b/lib/base.php index 74693641f6e..fa4c9850a3b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -428,7 +428,7 @@ class OC{ $parent = OC::$APPSROOT . '/' . self::$REQUESTEDAPP; if(!OC_Helper::issubdirectory($subdir, $parent)){ self::$REQUESTEDFILE = null; - //header('HTTP/1.0 404 Not Found'); + header('HTTP/1.0 404 Not Found'); exit; } } diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index cc37bf22d5d..912c8cd439a 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -50,7 +50,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $path = $this->path . '/' . $name; - if (!OC_Filesystem::file_exists($path)) throw new Sabre_DAV_Exception_FileNotFound('File with name ' . $path . ' could not be located'); + if (!OC_Filesystem::file_exists($path)) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located'); if (OC_Filesystem::is_dir($path)) { diff --git a/lib/connector/sabre/principal.php b/lib/connector/sabre/principal.php index 28a36438e87..d1456f7c642 100644 --- a/lib/connector/sabre/principal.php +++ b/lib/connector/sabre/principal.php @@ -46,7 +46,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { * @return array */ public function getPrincipalByPath($path) { - list($prefix,$name) = Sabre_DAV_URLUtil::splitPath($path); + list($prefix,$name) = explode('/', $path); if ($prefix == 'principals' && OC_User::userExists($name)) { return array( @@ -115,4 +115,6 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { public function setGroupMemberSet($principal, array $members) { throw new Sabre_DAV_Exception('Setting members of the group is not supported yet'); } + function updatePrincipal($path, $mutations){return 0;} + function searchPrincipals($prefixPath, array $searchProperties){return 0;} } diff --git a/lib/filecache.php b/lib/filecache.php index 19286ff746b..28a9eb247a6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -64,7 +64,7 @@ class OC_FileCache{ if(is_array($result)){ return $result; }else{ - OC_Log::write('get(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','get(): file not found in cache ('.$path.')',OC_Log::DEBUG); return false; } } @@ -257,7 +257,7 @@ class OC_FileCache{ if(is_array($result)){ return $result; }else{ - OC_Log::write('getFolderContent(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','getFolderContent(): file not found in cache ('.$path.')',OC_Log::DEBUG); return false; } } @@ -300,7 +300,7 @@ class OC_FileCache{ if(is_array($result)){ return $result['id']; }else{ - OC_Log::write('getFileId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','getFileId(): file not found in cache ('.$path.')',OC_Log::DEBUG); return -1; } } @@ -414,8 +414,12 @@ class OC_FileCache{ } return $result; }else{ - OC_Log::write('get(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); - return false; + OC_Log::write('files','getChached(): file not found in cache ('.$path.')',OC_Log::DEBUG); + if(isset(self::$savedData[$path])){ + return self::$savedData[$path]; + }else{ + return array(); + } } } @@ -553,6 +557,7 @@ class OC_FileCache{ $view=new OC_FilesystemView(($root=='/')?'':$root); } if(!$view->is_readable($path)) return; //cant read, nothing we can do + clearstatcache(); $stat=$view->stat($path); $mimetype=$view->getMimeType($path); $writable=$view->is_writable($path); diff --git a/lib/filesystem.php b/lib/filesystem.php index dc678fba74c..1b91eabc7c1 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -196,10 +196,58 @@ class OC_Filesystem{ return false; } self::$defaultInstance=new OC_FilesystemView($root); + + //load custom mount config + if(is_file(OC::$SERVERROOT.'/config/mount.php')){ + $mountConfig=include(OC::$SERVERROOT.'/config/mount.php'); + if(isset($mountConfig['global'])){ + foreach($mountConfig['global'] as $mountPoint=>$options){ + self::mount($options['class'],$options['options'],$mountPoint); + } + } + + if(isset($mountConfig['group'])){ + foreach($mountConfig['group'] as $group=>$mounts){ + if(OC_Group::inGroup(OC_User::getUser(),$group)){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + + if(isset($mountConfig['user'])){ + foreach($mountConfig['user'] as $user=>$mounts){ + if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + } + self::$loaded=true; } /** + * fill in the correct values for $user, and $password placeholders + * @param string intput + * @return string + */ + private static function setUserVars($input){ + return str_replace('$user',OC_User::getUser(),$input); + } + + /** * get the default filesystem view * @return OC_FilesystemView */ diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 95873bd87cf..ac5a0a3bff5 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -136,15 +136,16 @@ class OC_FilesystemView { return $this->basicOperation('filesize',$path); } public function readfile($path){ + @ob_end_clean(); $handle=$this->fopen($path,'r'); if ($handle) { - $chunkSize = 1024*1024;// 1 MB chunks + $chunkSize = 8*1024;// 1 MB chunks while (!feof($handle)) { echo fread($handle, $chunkSize); - @ob_flush(); flush(); } - return $this->filesize($path); + $size=$this->filesize($path); + return $size; } return false; } @@ -174,11 +175,23 @@ class OC_FilesystemView { } public function file_put_contents($path,$data){ if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier + $exists=$this->file_exists($path); + $run=true; + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + } + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + if(!$run){ + return false; + } $target=$this->fopen($path,'w'); if($target){ $count=OC_Helper::streamCopy($data,$target); fclose($target); fclose($data); + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path)); + } OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path)); return $count>0; }else{ diff --git a/lib/helper.php b/lib/helper.php index 1d9862bf8b1..c5af76dbe52 100755 --- a/lib/helper.php +++ b/lib/helper.php @@ -569,14 +569,22 @@ class OC_Helper { return false; } if($realpath_sub && $realpath_sub != '' && $realpath_parent && $realpath_parent != ''){ - if(substr($sub, 0, strlen($parent)) == $parent){ + if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent){ return true; } }else{ - if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent){ + if(substr($sub, 0, strlen($parent)) == $parent){ return true; } } + /* + echo 'SUB: ' . $sub . "\n"; + echo 'PAR: ' . $parent . "\n"; + echo 'REALSUB: ' . $realpath_sub . "\n"; + echo 'REALPAR: ' . $realpath_parent . "\n"; + echo substr($realpath_sub, 0, strlen($realpath_parent)); + exit; + */ return false; } } diff --git a/lib/vobject.php b/lib/vobject.php index e3479fc6d36..ec80e1d605a 100644 --- a/lib/vobject.php +++ b/lib/vobject.php @@ -41,7 +41,7 @@ class OC_VObject{ */ public static function parse($data){ try { - Sabre_VObject_Reader::$elementMap['LAST-MODIFIED'] = 'Sabre_VObject_Element_DateTime'; + Sabre_VObject_Property::$classMap['LAST-MODIFIED'] = 'Sabre_VObject_Property_DateTime'; $vobject = Sabre_VObject_Reader::read($data); if ($vobject instanceof Sabre_VObject_Component){ $vobject = new OC_VObject($vobject); @@ -150,12 +150,12 @@ class OC_VObject{ * @param int $dateType * @return void */ - public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Element_DateTime::LOCALTZ){ + public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Property_DateTime::LOCALTZ){ if ($datetime == 'now'){ $datetime = new DateTime(); } if ($datetime instanceof DateTime){ - $datetime_element = new Sabre_VObject_Element_DateTime($name); + $datetime_element = new Sabre_VObject_Property_DateTime($name); $datetime_element->setDateTime($datetime, $dateType); $this->vobject->__set($name, $datetime_element); }else{ |