Merge pull request #57538 from nextcloud/backport/57493/stable31

[stable31] fix: handle InvalidArumentException as availability failure in smb->getFileInfo
This commit is contained in:
Andy Scherzinger 2026-01-19 00:30:34 +01:00 committed by GitHub
commit ed7e49a306
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -169,13 +169,21 @@ class SMB extends Common implements INotifyStorage {
}
} 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);
}