Skip to content

Commit 4febe10

Browse files
authored
Merge pull request #48345 from nextcloud/fix/files_external/forbidden-exception
fix(files_external): Catch correct exception
2 parents 9a22098 + c8a90e9 commit 4febe10

File tree

1 file changed

+9
-7
lines changed
  • apps/files_external/lib/Lib/Storage

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ protected function relativePath($fullPath) {
160160
* @param string $path
161161
* @return IFileInfo
162162
* @throws StorageAuthException
163+
* @throws \OCP\Files\NotFoundException
164+
* @throws \OCP\Files\ForbiddenException
163165
*/
164166
protected function getFileInfo($path) {
165167
try {
@@ -336,7 +338,7 @@ public function rename($source, $target, $retry = true): bool {
336338
public function stat($path, $retry = true) {
337339
try {
338340
$result = $this->formatInfo($this->getFileInfo($path));
339-
} catch (ForbiddenException $e) {
341+
} catch (\OCP\Files\ForbiddenException $e) {
340342
return false;
341343
} catch (\OCP\Files\NotFoundException $e) {
342344
return false;
@@ -557,7 +559,7 @@ public function getMetaData($path) {
557559
$fileInfo = $this->getFileInfo($path);
558560
} catch (\OCP\Files\NotFoundException $e) {
559561
return null;
560-
} catch (ForbiddenException $e) {
562+
} catch (\OCP\Files\ForbiddenException $e) {
561563
return null;
562564
}
563565
if (!$fileInfo) {
@@ -633,7 +635,7 @@ public function filetype($path) {
633635
return $this->getFileInfo($path)->isDirectory() ? 'dir' : 'file';
634636
} catch (\OCP\Files\NotFoundException $e) {
635637
return false;
636-
} catch (ForbiddenException $e) {
638+
} catch (\OCP\Files\ForbiddenException $e) {
637639
return false;
638640
}
639641
}
@@ -668,7 +670,7 @@ public function file_exists($path) {
668670
return true;
669671
} catch (\OCP\Files\NotFoundException $e) {
670672
return false;
671-
} catch (ForbiddenException $e) {
673+
} catch (\OCP\Files\ForbiddenException $e) {
672674
return false;
673675
} catch (ConnectException $e) {
674676
throw new StorageNotAvailableException($e->getMessage(), (int)$e->getCode(), $e);
@@ -681,7 +683,7 @@ public function isReadable($path) {
681683
return $this->showHidden || !$info->isHidden();
682684
} catch (\OCP\Files\NotFoundException $e) {
683685
return false;
684-
} catch (ForbiddenException $e) {
686+
} catch (\OCP\Files\ForbiddenException $e) {
685687
return false;
686688
}
687689
}
@@ -694,7 +696,7 @@ public function isUpdatable($path) {
694696
return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $info->isDirectory());
695697
} catch (\OCP\Files\NotFoundException $e) {
696698
return false;
697-
} catch (ForbiddenException $e) {
699+
} catch (\OCP\Files\ForbiddenException $e) {
698700
return false;
699701
}
700702
}
@@ -705,7 +707,7 @@ public function isDeletable($path) {
705707
return ($this->showHidden || !$info->isHidden()) && !$info->isReadOnly();
706708
} catch (\OCP\Files\NotFoundException $e) {
707709
return false;
708-
} catch (ForbiddenException $e) {
710+
} catch (\OCP\Files\ForbiddenException $e) {
709711
return false;
710712
}
711713
}

0 commit comments

Comments
 (0)