Merge pull request #21128 from owncloud/dav-fopen-non-existing

Dont do a seperate request to check if a file exists when downloading a file from dav external storage
This commit is contained in:
Thomas Müller 2015-12-11 10:48:22 +01:00
commit ecc3c174a0
1 changed files with 14 additions and 8 deletions

View File

@ -34,6 +34,7 @@
namespace OC\Files\Storage;
use Exception;
use GuzzleHttp\Exception\RequestException;
use OC\Files\Filesystem;
use OC\Files\Stream\Close;
use Icewind\Streams\IteratorDirectory;
@ -339,15 +340,20 @@ class DAV extends Common {
switch ($mode) {
case 'r':
case 'rb':
if (!$this->file_exists($path)) {
return false;
try {
$response = $this->httpClientService
->newClient()
->get($this->createBaseUri() . $this->encodePath($path), [
'auth' => [$this->user, $this->password],
'stream' => true
]);
} catch (RequestException $e) {
if ($e->getResponse()->getStatusCode() === 404) {
return false;
} else {
throw $e;
}
}
$response = $this->httpClientService
->newClient()
->get($this->createBaseUri() . $this->encodePath($path), [
'auth' => [$this->user, $this->password],
'stream' => true
]);
if ($response->getStatusCode() !== Http::STATUS_OK) {
if ($response->getStatusCode() === Http::STATUS_LOCKED) {