Dropbox stream download with RetryWrapper

This commit is contained in:
Vincent Petry 2016-03-23 15:38:20 +01:00
parent 443d72ee87
commit 195cf4111e
1 changed files with 6 additions and 4 deletions

View File

@ -29,7 +29,9 @@
namespace OC\Files\Storage; namespace OC\Files\Storage;
use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory; use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;
require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php'; require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php';
@ -257,10 +259,9 @@ class Dropbox extends \OC\Files\Storage\Common {
$client = \OC::$server->getHTTPClientService()->newClient(); $client = \OC::$server->getHTTPClientService()->newClient();
try { try {
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); $response = $client->get($downloadUrl, [
$client->get($downloadUrl, [
'headers' => $headers, 'headers' => $headers,
'save_to' => $tmpFile, 'stream' => true,
]); ]);
} catch (RequestException $e) { } catch (RequestException $e) {
if (!is_null($e->getResponse())) { if (!is_null($e->getResponse())) {
@ -274,7 +275,8 @@ class Dropbox extends \OC\Files\Storage\Common {
} }
} }
return fopen($tmpFile, 'r'); $handle = $response->getBody();
return RetryWrapper::wrap($handle);
} catch (\Exception $exception) { } catch (\Exception $exception) {
\OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR); \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false; return false;