Merge pull request #14424 from nextcloud/fix/13554/swift_to_tmp

Use a tmp file for swift writes
This commit is contained in:
Roeland Jago Douma 2019-03-06 15:33:15 +01:00 committed by GitHub
commit 1b27e9578d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,9 +76,18 @@ class Swift implements IObjectStore {
* @throws \Exception from openstack lib when something goes wrong * @throws \Exception from openstack lib when something goes wrong
*/ */
public function writeObject($urn, $stream) { 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([ $this->getContainer()->createObject([
'name' => $urn, 'name' => $urn,
'stream' => stream_for($stream) 'stream' => stream_for($handle)
]); ]);
} }