diff options
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 5c8804695bd..85b4e620755 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -55,6 +55,7 @@ use OCA\Files_External\Lib\Notify\SMBNotifyHandler; use OCP\Files\Notify\IChange; use OCP\Files\Notify\IRenameChange; use OCP\Files\Storage\INotifyStorage; +use OCP\Files\StorageAuthException; use OCP\Files\StorageNotAvailableException; use OCP\ILogger; @@ -160,7 +161,7 @@ class SMB extends Common implements INotifyStorage { /** * @param string $path * @return \Icewind\SMB\IFileInfo - * @throws StorageNotAvailableException + * @throws StorageAuthException */ protected function getFileInfo($path) { try { @@ -170,20 +171,27 @@ class SMB extends Common implements INotifyStorage { } return $this->statCache[$path]; } catch (ConnectException $e) { - $this->logger->logException($e, ['message' => 'Error while getting file info']); - throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e); + $this->throwUnavailable($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->logger->logException($e, ['message' => 'Error while getting file info']); - throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e); + $this->throwUnavailable($e); } throw $e; } } /** + * @param \Exception $e + * @throws StorageAuthException + */ + protected function throwUnavailable(\Exception $e) { + $this->logger->logException($e, ['message' => 'Error while getting file info']); + throw new StorageAuthException($e->getMessage(), $e); + } + + /** * @param string $path * @return \Icewind\SMB\IFileInfo[] * @throws StorageNotAvailableException |