Skip to content

Commit

Permalink
Merge pull request #49880 from nextcloud/fix/view/catch-mkdir-excepti…
Browse files Browse the repository at this point in the history
…on-non-existent-parents

fix(View): Catch exceptions when executing mkdir for non-existent parents
  • Loading branch information
provokateurin authored Dec 17, 2024
2 parents 5f00a26 + 4bc0b58 commit f16d047
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down

0 comments on commit f16d047

Please sign in to comment.