summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-03-06 15:33:15 +0100
committerGitHub <noreply@github.com>2019-03-06 15:33:15 +0100
commit1b27e9578d3428771e9364bed57dcbe4c372921e (patch)
tree97cae1a7faea616d4d7f434dc194aa32086d57b1 /lib
parent540ec4f3df1b04a57c7b4e973ef4833184fc811b (diff)
parent1153123b90c7082723513f84243131860bbc649d (diff)
downloadnextcloud-server-1b27e9578d3428771e9364bed57dcbe4c372921e.tar.gz
nextcloud-server-1b27e9578d3428771e9364bed57dcbe4c372921e.zip
Merge pull request #14424 from nextcloud/fix/13554/swift_to_tmp
Use a tmp file for swift writes
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/ObjectStore/Swift.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php
index 3d6bf9d69da..7e4654b6eb2 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -76,9 +76,18 @@ class Swift implements IObjectStore {
* @throws \Exception from openstack lib when something goes wrong
*/
public function writeObject($urn, $stream) {
+ $handle = $stream;
+
+ $meta = stream_get_meta_data($stream);
+ if (!(isset($meta['seekable']) && $meta['seekable'] === true)) {
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite');
+ file_put_contents($tmpFile, $stream);
+ $handle = fopen($tmpFile, 'rb');
+ }
+
$this->getContainer()->createObject([
'name' => $urn,
- 'stream' => stream_for($stream)
+ 'stream' => stream_for($handle)
]);
}