[Pkg-owncloud-commits] [owncloud] 09/22: Stream downloads from Swift object stores without downloading it first

David Prévot taffit at moszumanska.debian.org
Fri Aug 29 14:48:56 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit ffdcab6cd5aa234122aa6b434d7c8741ebb7314e
Author: Robin Appelman <icewind at owncloud.com>
Date:   Fri Aug 22 14:11:21 2014 +0200

    Stream downloads from Swift object stores without downloading it first
---
 lib/private/files/objectstore/swift.php | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/private/files/objectstore/swift.php b/lib/private/files/objectstore/swift.php
index 3378fd7..1e8dd6a 100644
--- a/lib/private/files/objectstore/swift.php
+++ b/lib/private/files/objectstore/swift.php
@@ -120,12 +120,11 @@ class Swift implements IObjectStore {
 		$objectContent = $object->getContent();
 		$objectContent->rewind();
 
-		// directly returning the object stream does not work because the GC seems to collect it, so we need a copy
-		$tmpStream = fopen('php://temp', 'r+');
-		stream_copy_to_stream($objectContent->getStream(), $tmpStream);
-		rewind($tmpStream);
+		$stream = $objectContent->getStream();
+		// save the object content in the context of the stream to prevent it being gc'd until the stream is closed
+		stream_context_set_option($stream, 'swift','content', $objectContent);
 
-		return $tmpStream;
+		return $stream;
 	}
 
 	/**

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



More information about the Pkg-owncloud-commits mailing list