From 97f5c095f4018119e15d7c612a685da1dc91a340 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 10 Dec 2015 17:13:02 +0100 Subject: [PATCH] Dont do a seperate request to check if a file exists for dav->fopen --- lib/private/files/storage/dav.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php index dda163e41a0..9afebab1dd7 100644 --- a/lib/private/files/storage/dav.php +++ b/lib/private/files/storage/dav.php @@ -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) { -- 2.39.5