Pārlūkot izejas kodu

fix ZF-6648

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15581 44c647ce-9c0f-0410-b52a-842ac1e357ba
stas 16 gadi atpakaļ
vecāks
revīzija
73544680df
1 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 19 5
      library/Zend/Service/Amazon/S3/Stream.php

+ 19 - 5
library/Zend/Service/Amazon/S3/Stream.php

@@ -113,7 +113,7 @@ class Zend_Service_Amazon_S3_Stream
     {
         $url = parse_url($path);
         if ($url['host']) {
-            return $url['path'] ? $url['host'].$url['path'] : $url['host'];
+            return !empty($url['path']) ? $url['host'].$url['path'] : $url['host'];
         }
 
         return '';
@@ -319,7 +319,7 @@ class Zend_Service_Amazon_S3_Stream
         $stat = array();
         $stat['dev'] = 0;
         $stat['ino'] = 0;
-        $stat['mode'] = 0;
+        $stat['mode'] = 0777;
         $stat['nlink'] = 0;
         $stat['uid'] = 0;
         $stat['gid'] = 0;
@@ -331,7 +331,13 @@ class Zend_Service_Amazon_S3_Stream
         $stat['blksize'] = 0;
         $stat['blocks'] = 0;
 
-        $info = $this->_s3->getInfo($this->_objectName);
+	if(($slash = strchr($this->_objectName, '/')) === false || $slash == strlen($this->_objectName)-1) {
+		/* bucket */
+		$stat['mode'] |= 040000;
+	} else {
+		$stat['mode'] |= 0100000;
+	}
+       	$info = $this->_s3->getInfo($this->_objectName);
         if (!empty($info)) {
             $stat['size']  = $info['size'];
             $stat['atime'] = time();
@@ -423,7 +429,7 @@ class Zend_Service_Amazon_S3_Stream
         $stat = array();
         $stat['dev'] = 0;
         $stat['ino'] = 0;
-        $stat['mode'] = 0;
+        $stat['mode'] = 0777;
         $stat['nlink'] = 0;
         $stat['uid'] = 0;
         $stat['gid'] = 0;
@@ -435,7 +441,15 @@ class Zend_Service_Amazon_S3_Stream
         $stat['blksize'] = 0;
         $stat['blocks'] = 0;
 
-        $info = $this->_getS3Client($path)->getInfo($this->_getNamePart($path));
+	$name = $this->_getNamePart($path);
+	if(($slash = strchr($name, '/')) === false || $slash == strlen($name)-1) {
+		/* bucket */
+		$stat['mode'] |= 040000;
+	} else {
+		$stat['mode'] |= 0100000;
+	}
+       	$info = $this->_getS3Client($path)->getInfo($name);
+
         if (!empty($info)) {
             $stat['size']  = $info['size'];
             $stat['atime'] = time();