Skip to content

Commit

Permalink
Dont do a seperate request to check if a file exists for dav->fopen
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Dec 10, 2015
1 parent 75c3d64 commit 97f5c09
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/private/files/storage/dav.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -339,15 +340,20 @@ public function fopen($path, $mode) {
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) {
Expand Down

0 comments on commit 97f5c09

Please sign in to comment.