Skip to content

Commit ed7e49a

Browse files
Merge pull request #57538 from nextcloud/backport/57493/stable31
[stable31] fix: handle InvalidArumentException as availability failure in smb->getFileInfo
2 parents 89d171a + e5659a7 commit ed7e49a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • apps/files_external/lib/Lib/Storage

apps/files_external/lib/Lib/Storage/SMB.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,21 @@ protected function getFileInfo(string $path): IFileInfo {
169169
}
170170
} catch (ConnectException $e) {
171171
$this->throwUnavailable($e);
172+
} catch (InvalidArgumentException $e) {
173+
$this->throwUnavailable($e);
172174
} catch (NotFoundException $e) {
173175
throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e);
174176
} catch (ForbiddenException $e) {
175177
// with php-smbclient, this exception is thrown when the provided password is invalid.
176-
// Possible is also ForbiddenException with a different error code, so we check it.
177-
if ($e->getCode() === 1) {
178+
// we check if we can stat the root, which should only fail in authentication failures
179+
if ($path === '') {
178180
$this->throwUnavailable($e);
181+
} else {
182+
try {
183+
$this->share->stat('');
184+
} catch (\Exception $e) {
185+
$this->throwUnavailable($e);
186+
}
179187
}
180188
throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e);
181189
}

0 commit comments

Comments
 (0)