diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-08-22 13:19:51 +0300 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-08-22 13:40:15 +0300 |
commit | 43bc31bacb9082c02bc4b63fb1695ddcb1d7af84 (patch) | |
tree | 49400394359d9c38d0a11e867dde0fd99e9a4d77 /apps/files_external/lib | |
parent | cd62b38cc8a9176065955f6ed794ed78517b5dbb (diff) |
set a storage availability delay on auth issues to avoid lock out
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_external/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 |