aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-09-04 21:09:27 +0200
committerGitHub <noreply@github.com>2024-09-04 21:09:27 +0200
commit70651b6b3cbb1b1daa57444f2e0d7e80ec790137 (patch)
treebfae22b7125531592bc2847f3ce0a31c4f44c5d3
parente99137b6e4042bdb339a5d1b9ffe0fea97ed1512 (diff)
parent77c38979c60c3dfa1765e4a8f7472f46717fe427 (diff)
downloadnextcloud-server-70651b6b3cbb1b1daa57444f2e0d7e80ec790137.tar.gz
nextcloud-server-70651b6b3cbb1b1daa57444f2e0d7e80ec790137.zip
Merge pull request #47750 from nextcloud/backport/47417/stable29
-rw-r--r--lib/private/Files/View.php9
-rw-r--r--tests/lib/Files/ViewTest.php31
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 0de515d8481..efe3bcf5abc 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1531,6 +1531,15 @@ class View {
if ($pos = strpos($relativePath, '/')) {
//mountpoint inside subfolder add size to the correct folder
$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])) {
$files[$entryName]->addSubEntry($rootEntry, $mountPoint);
}
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index f67c4e9642b..16568e74a06 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -2743,4 +2743,35 @@ class ViewTest extends \Test\TestCase {
$this->assertFalse($cache->inCache('foo.txt'));
}
+
+ public function testMountpointParentsCreated() {
+ $storage1 = $this->getTestStorage();
+ Filesystem::mount($storage1, [], '/');
+
+ $storage2 = $this->getTestStorage();
+ Filesystem::mount($storage2, [], '/A/B/C');
+
+ $rootView = new View('');
+
+ $folderData = $rootView->getDirectoryContent('/');
+ $this->assertCount(4, $folderData);
+ $this->assertEquals('folder', $folderData[0]['name']);
+ $this->assertEquals('foo.png', $folderData[1]['name']);
+ $this->assertEquals('foo.txt', $folderData[2]['name']);
+ $this->assertEquals('A', $folderData[3]['name']);
+
+ $folderData = $rootView->getDirectoryContent('/A');
+ $this->assertCount(1, $folderData);
+ $this->assertEquals('B', $folderData[0]['name']);
+
+ $folderData = $rootView->getDirectoryContent('/A/B');
+ $this->assertCount(1, $folderData);
+ $this->assertEquals('C', $folderData[0]['name']);
+
+ $folderData = $rootView->getDirectoryContent('/A/B/C');
+ $this->assertCount(3, $folderData);
+ $this->assertEquals('folder', $folderData[0]['name']);
+ $this->assertEquals('foo.png', $folderData[1]['name']);
+ $this->assertEquals('foo.txt', $folderData[2]['name']);
+ }
}