aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-12-16 12:51:56 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-12-17 09:40:42 +0000
commit5cc14e261878aef3194957338df41885ba709bf4 (patch)
treea008f04a89ebda6a82317e30e7c75d6b09f98b58
parent03b3ac7cf50a00e7e3b3d8a3ef8eb25605b5752f (diff)
downloadnextcloud-server-5cc14e261878aef3194957338df41885ba709bf4.tar.gz
nextcloud-server-5cc14e261878aef3194957338df41885ba709bf4.zip
fix(View): Catch exceptions when executing mkdir for non-existent parentsbackport/49880/stable30
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--lib/private/Files/View.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index db2483fab76..738e1442b67 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1498,10 +1498,17 @@ class View {
$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]);
}
}