Skip to content

Commit

Permalink
Dropbox stream download with RetryWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Mar 23, 2016
1 parent ea07a42 commit 02c2568
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apps/files_external/lib/dropbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

namespace OC\Files\Storage;

use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;

require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php';

Expand Down Expand Up @@ -257,10 +259,9 @@ public function fopen($path, $mode) {

$client = \OC::$server->getHTTPClientService()->newClient();
try {
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
$client->get($downloadUrl, [
$response = $client->get($downloadUrl, [
'headers' => $headers,
'save_to' => $tmpFile,
'stream' => true,
]);
} catch (RequestException $e) {
if (!is_null($e->getResponse())) {
Expand All @@ -274,7 +275,8 @@ public function fopen($path, $mode) {
}
}

return fopen($tmpFile, 'r');
$handle = $response->getBody();
return RetryWrapper::wrap($handle);
} catch (\Exception $exception) {
\OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
Expand Down

0 comments on commit 02c2568

Please sign in to comment.