diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 66894e0c3cff3..e97cd75251d8d 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1512,10 +1512,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]); } }