Merge pull request #57493 from nextcloud/smb-invalid-arg-unavailable

fix: handle InvalidArumentException as availability failure in smb->getFileInfo
This commit is contained in:
Robin Appelman 2026-01-14 12:00:03 +01:00 committed by GitHub
commit 9fde2523e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -172,13 +172,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);
}