Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ protected function refreshInfo(): void {
$root = Server::get(IRootFolder::class);
$rootView = Server::get(View::class);
if ($this->info->getType() === FileInfo::TYPE_FOLDER) {
$this->node = new Folder($root, $rootView, $this->path, $this->info);
$this->node = new Folder($root, $rootView, $this->fileView->getAbsolutePath($this->path), $this->info);
} else {
$this->node = new File($root, $rootView, $this->path, $this->info);
$this->node = new File($root, $rootView, $this->fileView->getAbsolutePath($this->path), $this->info);
}
}

Expand Down
31 changes: 31 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OC\Files\Node\Folder;
use OC\Files\View;
use OC\Share20\ShareAttributes;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\Files_Sharing\SharedMount;
use OCA\Files_Sharing\SharedStorage;
Expand All @@ -33,6 +34,36 @@
*/
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
class NodeTest extends \Test\TestCase {
public static function refreshNodeTypesProvider(): array {
return [
'file' => [File::class, FileInfo::TYPE_FILE],
'folder' => [Directory::class, FileInfo::TYPE_FOLDER],
];
}

/** @param class-string<File|Directory> $nodeClass */
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'refreshNodeTypesProvider')]
public function testTouchKeepsAbsoluteNodePath(string $nodeClass, string $type): void {
$viewRoot = '/test-user/files';
$relativePath = '/documents/entry';
$absolutePath = $viewRoot . $relativePath;
$info = $this->createConfiguredMock(FileInfo::class, [
'getPath' => $absolutePath,
'getType' => $type,
]);
$view = $this->getMockBuilder(View::class)
->setConstructorArgs([$viewRoot])
->onlyMethods(['touch', 'getFileInfo'])
->getMock();
$view->expects($this->once())->method('touch')->with($relativePath, 123456789);
$view->expects($this->once())->method('getFileInfo')->with($relativePath)->willReturn($info);

$node = new $nodeClass($view, $info);
$node->touch('123456789');

$this->assertSame($absolutePath, $node->getNode()->getPath());
}

public static function davPermissionsProvider(): array {
return [
[Constants::PERMISSION_ALL, 'file', false, Constants::PERMISSION_ALL, false, 'test', 'RGDNVW'],
Expand Down