Skip to content

Commit

Permalink
fix(View): Catch exceptions when executing mkdir for non-existent par…
Browse files Browse the repository at this point in the history
…ents

Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin authored and backportbot[bot] committed Dec 17, 2024
1 parent bd932b6 commit 6393707
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 @@ -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]);
}
}

Expand Down

0 comments on commit 6393707

Please sign in to comment.