Skip to content

Commit 9fde252

Browse files
authored
Merge pull request #57493 from nextcloud/smb-invalid-arg-unavailable
fix: handle InvalidArumentException as availability failure in smb->getFileInfo
2 parents ad8576f + 4dcd422 commit 9fde252

File tree

1 file changed

+10
-2
lines changed
  • apps/files_external/lib/Lib/Storage

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,21 @@ protected function getFileInfo(string $path): IFileInfo {
172172
}
173173
} catch (ConnectException $e) {
174174
$this->throwUnavailable($e);
175+
} catch (InvalidArgumentException $e) {
176+
$this->throwUnavailable($e);
175177
} catch (NotFoundException $e) {
176178
throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e);
177179
} catch (ForbiddenException $e) {
178180
// with php-smbclient, this exception is thrown when the provided password is invalid.
179-
// Possible is also ForbiddenException with a different error code, so we check it.
180-
if ($e->getCode() === 1) {
181+
// we check if we can stat the root, which should only fail in authentication failures
182+
if ($path === '') {
181183
$this->throwUnavailable($e);
184+
} else {
185+
try {
186+
$this->share->stat('');
187+
} catch (\Exception $e) {
188+
$this->throwUnavailable($e);
189+
}
182190
}
183191
throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e);
184192
}

0 commit comments

Comments
 (0)