diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index a4a68b2f4a718..50e860c83fc21 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1529,10 +1529,17 @@ public function getDirectoryContent($directory, $mimetype_filter = '', \OCP\File $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]); } }