From c8a90e941a8b2add613dc1d0555bb5d5fbad08d5 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 25 Sep 2024 09:07:33 +0200 Subject: [PATCH] fix(files_external): Catch correct exception SMB#getFileInfo used to throw an icewind/smb exception, but nowadays throws \OCP\Files\ForbiddenException. This fixes downstream methods to catch the new exception. Signed-off-by: Marcel Klehr --- apps/files_external/lib/Lib/Storage/SMB.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 7517c180e3793..91a6eab8d09fc 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -160,6 +160,8 @@ protected function relativePath($fullPath) { * @param string $path * @return IFileInfo * @throws StorageAuthException + * @throws \OCP\Files\NotFoundException + * @throws \OCP\Files\ForbiddenException */ protected function getFileInfo($path) { try { @@ -336,7 +338,7 @@ public function rename($source, $target, $retry = true): bool { public function stat($path, $retry = true) { try { $result = $this->formatInfo($this->getFileInfo($path)); - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } catch (\OCP\Files\NotFoundException $e) { return false; @@ -557,7 +559,7 @@ public function getMetaData($path) { $fileInfo = $this->getFileInfo($path); } catch (\OCP\Files\NotFoundException $e) { return null; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return null; } if (!$fileInfo) { @@ -633,7 +635,7 @@ public function filetype($path) { return $this->getFileInfo($path)->isDirectory() ? 'dir' : 'file'; } catch (\OCP\Files\NotFoundException $e) { return false; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } } @@ -668,7 +670,7 @@ public function file_exists($path) { return true; } catch (\OCP\Files\NotFoundException $e) { return false; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } catch (ConnectException $e) { throw new StorageNotAvailableException($e->getMessage(), (int)$e->getCode(), $e); @@ -681,7 +683,7 @@ public function isReadable($path) { return $this->showHidden || !$info->isHidden(); } catch (\OCP\Files\NotFoundException $e) { return false; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } } @@ -694,7 +696,7 @@ public function isUpdatable($path) { return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $info->isDirectory()); } catch (\OCP\Files\NotFoundException $e) { return false; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } } @@ -705,7 +707,7 @@ public function isDeletable($path) { return ($this->showHidden || !$info->isHidden()) && !$info->isReadOnly(); } catch (\OCP\Files\NotFoundException $e) { return false; - } catch (ForbiddenException $e) { + } catch (\OCP\Files\ForbiddenException $e) { return false; } }