Dont do a seperate request to check if a file exists for dav->fopen
This commit is contained in:
parent
75c3d64635
commit
97f5c095f4
1 changed files with 14 additions and 8 deletions
|
@ -34,6 +34,7 @@
|
||||||
namespace OC\Files\Storage;
|
namespace OC\Files\Storage;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use OC\Files\Filesystem;
|
use OC\Files\Filesystem;
|
||||||
use OC\Files\Stream\Close;
|
use OC\Files\Stream\Close;
|
||||||
use Icewind\Streams\IteratorDirectory;
|
use Icewind\Streams\IteratorDirectory;
|
||||||
|
@ -339,15 +340,20 @@ class DAV extends Common {
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'rb':
|
case 'rb':
|
||||||
if (!$this->file_exists($path)) {
|
try {
|
||||||
return false;
|
$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_OK) {
|
||||||
if ($response->getStatusCode() === Http::STATUS_LOCKED) {
|
if ($response->getStatusCode() === Http::STATUS_LOCKED) {
|
||||||
|
|
Loading…
Reference in a new issue