diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 049509fa21c0c..577dbb7bff358 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -191,13 +191,15 @@ protected function getFileInfo($path) { return $this->statCache[$path]; } catch (ConnectException $e) { $this->throwUnavailable($e); + } catch (NotFoundException $e) { + throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e); } catch (ForbiddenException $e) { // with php-smbclient, this exceptions is thrown when the provided password is invalid. // Possible is also ForbiddenException with a different error code, so we check it. if ($e->getCode() === 1) { $this->throwUnavailable($e); } - throw $e; + throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e); } } @@ -341,7 +343,7 @@ public function stat($path, $retry = true) { $result = $this->formatInfo($this->getFileInfo($path)); } catch (ForbiddenException $e) { return false; - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (TimedOutException $e) { if ($retry) { @@ -558,7 +560,7 @@ public function touch($path, $mtime = null) { public function getMetaData($path) { try { $fileInfo = $this->getFileInfo($path); - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return null; } catch (ForbiddenException $e) { return null; @@ -628,7 +630,7 @@ public function getDirectoryContent($directory): \Traversable { public function filetype($path) { try { return $this->getFileInfo($path)->isDirectory() ? 'dir' : 'file'; - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; @@ -652,7 +654,7 @@ public function file_exists($path) { try { $this->getFileInfo($path); return true; - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; @@ -665,7 +667,7 @@ public function isReadable($path) { try { $info = $this->getFileInfo($path); return $this->showHidden || !$info->isHidden(); - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; @@ -678,7 +680,7 @@ public function isUpdatable($path) { // following windows behaviour for read-only folders: they can be written into // (https://support.microsoft.com/en-us/kb/326549 - "cause" section) return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $info->isDirectory()); - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; @@ -689,7 +691,7 @@ public function isDeletable($path) { try { $info = $this->getFileInfo($path); return ($this->showHidden || !$info->isHidden()) && !$info->isReadOnly(); - } catch (NotFoundException $e) { + } catch (\OCP\Files\NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; @@ -714,6 +716,10 @@ public static function checkDependencies() { public function test() { try { return parent::test(); + } catch (StorageAuthException $e) { + return false; + } catch (ForbiddenException $e) { + return false; } catch (Exception $e) { $this->logger->logException($e); return false;