diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-11 22:54:39 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-11 22:54:39 +0200 |
commit | fb2d2bc2011c371ff1e4334f84494f15a84a07a2 (patch) | |
tree | b5c20c842441ce4288038909daa5a158c8e74e80 /apps/files_external/lib | |
parent | 5c6e9518edde10e0c23d0d734d2cc6d161fc15c0 (diff) | |
parent | ee28e35ba93032a3d43601c030d3d44df9b092f0 (diff) | |
download | nextcloud-server-fb2d2bc2011c371ff1e4334f84494f15a84a07a2.tar.gz nextcloud-server-fb2d2bc2011c371ff1e4334f84494f15a84a07a2.zip |
merge master into filesystem
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/smb.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/swift.php | 38 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 3 |
3 files changed, 31 insertions, 12 deletions
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index d4882ed0249..8fcdd1f722f 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -61,7 +61,7 @@ class SMB extends \OC\Files\Storage\StreamWrapper{ } public function filetype($path) { - return (bool)@$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go + return (bool)@$this->opendir($path) ? 'dir' : 'file';//using opendir causes the same amount of requests and caches the content of the folder in one go } /** diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index c67cf59df6b..8d402b25212 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -41,7 +41,7 @@ class SWIFT extends \OC\Files\Storage\Common{ * @return string */ private function getContainerName($path) { - $path=trim($this->root.$path,'/'); + $path=trim(trim($this->root,'/')."/".$path,'/.'); return str_replace('/','\\',$path); } @@ -72,11 +72,11 @@ class SWIFT extends \OC\Files\Storage\Common{ * @return CF_Container */ private function createContainer($path) { - if($path=='' or $path=='/') { + if($path=='' or $path=='/' or $path=='.') { return $this->conn->create_container($this->getContainerName($path)); } $parent=dirname($path); - if($parent=='' or $parent=='/') { + if($parent=='' or $parent=='/' or $parent=='.') { $parentContainer=$this->rootContainer; }else{ if(!$this->containerExists($parent)) { @@ -102,6 +102,9 @@ class SWIFT extends \OC\Files\Storage\Common{ if(is_null($container)) { return null; }else{ + if ($path=="/" or $path=='') { + return null; + } try{ $obj=$container->get_object(basename($path)); $this->objects[$path]=$obj; @@ -137,7 +140,7 @@ class SWIFT extends \OC\Files\Storage\Common{ private function createObject($path) { $container=$this->getContainer(dirname($path)); if(!is_null($container)) { - $container=$this->createContainer($path); + $container=$this->createContainer(dirname($path)); } return $container->create_object(basename($path)); } @@ -279,7 +282,7 @@ class SWIFT extends \OC\Files\Storage\Common{ $this->conn = new \CF_Connection($this->auth); - if(!$this->containerExists($this->root)) { + if(!$this->containerExists('/')) { $this->rootContainer=$this->createContainer('/'); }else{ $this->rootContainer=$this->getContainer('/'); @@ -393,6 +396,9 @@ class SWIFT extends \OC\Files\Storage\Common{ } public function unlink($path) { + if($this->containerExists($path)) { + return $this->rmdir($path); + } if($this->objectExists($path)) { $container=$this->getContainer(dirname($path)); $container->delete_object(basename($path)); @@ -403,13 +409,13 @@ class SWIFT extends \OC\Files\Storage\Common{ } public function fopen($path,$mode) { - $obj=$this->getObject($path); - if(is_null($obj)) { - return false; - } switch($mode) { case 'r': case 'rb': + $obj=$this->getObject($path); + if (is_null($obj)) { + return false; + } $fp = fopen('php://temp', 'r+'); $obj->stream($fp); @@ -442,7 +448,7 @@ class SWIFT extends \OC\Files\Storage\Common{ } public function free_space($path) { - return 0; + return 1024*1024*1024*8; } public function touch($path,$mtime=null) { @@ -483,7 +489,17 @@ class SWIFT extends \OC\Files\Storage\Common{ } public function stat($path) { + $container=$this->getContainer($path); + if (!is_null($container)) { + return array( + 'mtime'=>-1, + 'size'=>$container->bytes_used, + 'ctime'=>-1 + ); + } + $obj=$this->getObject($path); + if(is_null($obj)) { return false; } @@ -507,7 +523,7 @@ class SWIFT extends \OC\Files\Storage\Common{ $obj->save_to_filename($tmpFile); return $tmpFile; }else{ - return false; + return OCP\Files::tmpFile(); } } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 70210b49ee7..7c61d06a018 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -133,6 +133,9 @@ class DAV extends \OC\Files\Storage\Common{ switch($mode) { case 'r': case 'rb': + if(!$this->file_exists($path)) { + return false; + } //straight up curl instead of sabredav here, sabredav put's the entire get result in memory $curl = curl_init(); $fp = fopen('php://temp', 'r+'); |