Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropbox stream download with RetryWrapper #23516

Merged
merged 1 commit into from
Mar 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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