]> source.dussan.org Git - nextcloud-server.git/commitdiff
Dont do a seperate request to check if a file exists for dav->fopen
authorRobin Appelman <icewind@owncloud.com>
Thu, 10 Dec 2015 16:13:02 +0000 (17:13 +0100)
committerRobin Appelman <icewind@owncloud.com>
Thu, 10 Dec 2015 16:23:53 +0000 (17:23 +0100)
lib/private/files/storage/dav.php

index dda163e41a0c961add8aecb5991d52584fe5f6d7..9afebab1dd76daf6d5b08edf5debb59c7b773e47 100644 (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) {