Skip to content

Commit

Permalink
fix(files_external): Catch correct exception
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marcelklehr authored and backportbot[bot] committed Sep 26, 2024
1 parent fa6f516 commit e98196b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,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 {
Expand Down Expand Up @@ -366,7 +368,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;
Expand Down Expand Up @@ -587,7 +589,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) {
Expand Down Expand Up @@ -663,7 +665,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;
}
}
Expand Down Expand Up @@ -698,7 +700,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);
Expand All @@ -711,7 +713,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;
}
}
Expand All @@ -724,7 +726,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;
}
}
Expand All @@ -735,7 +737,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;
}
}
Expand Down

0 comments on commit e98196b

Please sign in to comment.