Skip to content

Commit

Permalink
Merge pull request #14424 from nextcloud/fix/13554/swift_to_tmp
Browse files Browse the repository at this point in the history
Use a tmp file for swift writes
  • Loading branch information
rullzer authored Mar 6, 2019
2 parents 540ec4f + 1153123 commit 1b27e95
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/private/Files/ObjectStore/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,18 @@ public function getStorageId() {
* @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)
]);
}

Expand Down

0 comments on commit 1b27e95

Please sign in to comment.