From 9a728db5310699a174223e46d082fbbd7d28ca71 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Mon, 16 Dec 2024 12:51:56 +0100 Subject: [PATCH] fix(View): Catch exceptions when executing mkdir for non-existent parents Signed-off-by: provokateurin --- lib/private/Files/View.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index b6b136ab178cb..7e2d7a099662d 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1533,10 +1533,17 @@ public function getDirectoryContent($directory, $mimetype_filter = '', ?\OCP\Fil $entryName = substr($relativePath, 0, $pos); // Create parent folders if the mountpoint is inside a subfolder that doesn't exist yet - if (!isset($files[$entryName]) && $this->mkdir($path . '/' . $entryName) !== false) { - $info = $this->getFileInfo($path . '/' . $entryName); - if ($info !== false) { - $files[$entryName] = $info; + if (!isset($files[$entryName])) { + try { + if ($this->mkdir($path . '/' . $entryName) !== false) { + $info = $this->getFileInfo($path . '/' . $entryName); + if ($info !== false) { + $files[$entryName] = $info; + } + } + } catch (\Exception $e) { + // Creating the parent folder might not be possible, for example due to a lack of permissions. + $this->logger->debug('Failed to create non-existent parent', ['exception' => $e, 'path' => $path . '/' . $entryName]); } }