[Pkg-owncloud-commits] [php-sabredav] 111/148: Improvements suggested by @Hywan.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 84636edc5e68aeae8d550d32d5d5ce1a2ea31079
Author: dratini0 <dratini0 at gmail.com>
Date:   Thu Apr 2 10:49:10 2015 +0200

    Improvements suggested by @Hywan.
---
 lib/DAV/CorePlugin.php | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index e68576a..dd163b1 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -170,14 +170,16 @@ class CorePlugin extends ServerPlugin {
 
             }
 
-            // fseek will return 0 only if $stream is seekable (and -1 otherwise)
             // for a seekable $body stream we simply set the pointer
             // for a non-seekable $body stream we read and discard just the
-            //  right amount of data
-            if ((fseek($body, $start, SEEK_SET)) !== 0) {
-                $consume_block = 4096;
+            // right amount of data
+            if (stream_get_meta_data($body)['seekable']) {
+                fseek($body, $start, SEEK_SET);
+            } else {
+                $consumeBlock = 8192;
                 for($consumed = 0; $start - $consumed > 0; ){
-                    $consumed += strlen(fread($body, min($start - $consumed, $consume_block)));
+                    if(feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')');
+                    $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock)));
                 }
             }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list