Просмотр исходного кода

Zwnd_Service_Amazon_S3: S3 Stream wrapper incorrectly reads data fix. Closes [ZF-10299].

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23700 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 15 лет назад
Родитель
Сommit
c06fa2fa59
1 измененных файлов с 5 добавлено и 8 удалено
  1. 5 8
      library/Zend/Service/Amazon/S3/Stream.php

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

@@ -140,8 +140,7 @@ class Zend_Service_Amazon_S3_Stream
             $this->_writeBuffer = true;
             $this->_getS3Client($path);
             return true;
-        }
-        else {
+        } else {
             // Otherwise, just see if the file exists or not
             $info = $this->_getS3Client($path)->getInfo($name);
             if ($info) {
@@ -194,14 +193,12 @@ class Zend_Service_Amazon_S3_Stream
         }
 
         $range_start = $this->_position;
-        $range_end = $this->_position+$count;
+        $range_end   = $this->_position + $count - 1;
 
         // Only fetch more data from S3 if we haven't fetched any data yet (postion=0)
-        // OR, the range end position is greater than the size of the current object
-        // buffer AND if the range end position is less than or equal to the object's
-        // size returned by S3
-        if (($this->_position == 0) || (($range_end > strlen($this->_objectBuffer)) && ($range_end <= $this->_objectSize))) {
-
+        // OR, the range end position plus 1 is greater than the size of the current
+        // object buffer
+        if ($this->_objectBuffer === null  ||  $range_end >= strlen($this->_objectBuffer)) {
             $headers = array(
                 'Range' => "bytes=$range_start-$range_end"
             );