summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-09-09 16:50:42 +0200
committerGitHub <noreply@github.com>2019-09-09 16:50:42 +0200
commitbf6082e119d1c2420286dbcdbbfda1b1e196d9a0 (patch)
tree7a6f49b43a978551f9b61e95424c220eec96563f /apps
parent507eb30e1d7ab2ea31934796621cd6614c2af750 (diff)
parent4bd83c9a28daba6abeb7ad822b1bb8879f0639ad (diff)
downloadnextcloud-server-bf6082e119d1c2420286dbcdbbfda1b1e196d9a0.tar.gz
nextcloud-server-bf6082e119d1c2420286dbcdbbfda1b1e196d9a0.zip
Merge pull request #16836 from nextcloud/fix/16724/smb-availability
Fix SMB availability status + higher delay on auth issues
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index bff23160944..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,12 +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->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