Merge pull request #15203 from nextcloud/backport/15168/stable16

[stable16] Always use a temp file for swift writes
This commit is contained in:
Roeland Jago Douma 2019-04-24 15:51:31 +02:00 committed by GitHub
commit d3e6feb7de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 8 deletions

View File

@ -76,14 +76,9 @@ 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');
}
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite');
file_put_contents($tmpFile, $stream);
$handle = fopen($tmpFile, 'rb');
$this->getContainer()->createObject([
'name' => $urn,