diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 3d0a7063df78f..679e3ad791c4e 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -172,13 +172,21 @@ protected function getFileInfo(string $path): IFileInfo { } } catch (ConnectException $e) { $this->throwUnavailable($e); + } catch (InvalidArgumentException $e) { + $this->throwUnavailable($e); } catch (NotFoundException $e) { throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e); } catch (ForbiddenException $e) { // with php-smbclient, this exception 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) { + // we check if we can stat the root, which should only fail in authentication failures + if ($path === '') { $this->throwUnavailable($e); + } else { + try { + $this->share->stat(''); + } catch (\Exception $e) { + $this->throwUnavailable($e); + } } throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e); }