aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2024-09-05 10:55:12 +0200
committerGitHub <noreply@github.com>2024-09-05 10:55:12 +0200
commit4dfc5f69b020f065d88aa016bfaf55dbb00dba7c (patch)
tree3eea576a0bd9ea2553d3b16bb0bcd506abf7720d
parentf99f750eff47b368d5c97e22cb8e5cafe345cb85 (diff)
parente77ac5c8e12f3f67cbda58908d9d9b2ff68ad655 (diff)
downloadnextcloud-server-4dfc5f69b020f065d88aa016bfaf55dbb00dba7c.tar.gz
nextcloud-server-4dfc5f69b020f065d88aa016bfaf55dbb00dba7c.zip
Merge pull request #47749 from nextcloud/backport/47417/stable28
[stable28] fix(files): Create non-existent parents of mountpoints
-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 4aaea23e7f1..a4a68b2f4a7 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1527,6 +1527,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 b9dd49d71fe..ad22a7267e6 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -2742,4 +2742,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']);
+ }
}