summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/objectstore/swift.php9
-rw-r--r--lib/private/helper.php16
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/private/files/objectstore/swift.php b/lib/private/files/objectstore/swift.php
index 3378fd7b86f..1e8dd6a7401 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;
}
/**
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 17d3840a3ea..7c1edd1b058 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -579,8 +579,20 @@ class OC_Helper {
public static function tmpFile($postfix = '') {
$file = get_temp_dir() . '/' . md5(time() . rand()) . $postfix;
$fh = fopen($file, 'w');
- fclose($fh);
- self::$tmpFiles[] = $file;
+ if ($fh!==false){
+ fclose($fh);
+ self::$tmpFiles[] = $file;
+ } else {
+ OC_Log::write(
+ 'OC_Helper',
+ sprintf(
+ 'Can not create a temporary file in directory %s. Check it exists and has correct permissions',
+ get_temp_dir()
+ ),
+ OC_Log::WARN
+ );
+ $file = false;
+ }
return $file;
}