From d4b068dc1c427e5fc584946a65be25ed37bc8e22 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 15 Oct 2024 17:05:57 +0200 Subject: [PATCH] fix: include mountpoint in original location for trash items Signed-off-by: Robin Appelman --- lib/Trash/GroupTrashItem.php | 14 +++++++++----- lib/Trash/TrashBackend.php | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Trash/GroupTrashItem.php b/lib/Trash/GroupTrashItem.php index 7371f0487..819db698c 100644 --- a/lib/Trash/GroupTrashItem.php +++ b/lib/Trash/GroupTrashItem.php @@ -13,7 +13,7 @@ use OCP\IUser; class GroupTrashItem extends TrashItem { - private string $mountPoint; + private string $internalOriginalLocation; public function __construct( ITrashBackend $backend, @@ -22,11 +22,15 @@ public function __construct( string $trashPath, FileInfo $fileInfo, IUser $user, - string $mountPoint, - private ?IUser $deletedBy, + private string $mountPoint, + ?IUser $deletedBy, ) { - parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user, $deletedBy); - $this->mountPoint = $mountPoint; + $this->internalOriginalLocation = $originalLocation; + parent::__construct($backend, $this->mountPoint . '/' . $originalLocation, $deletedTime, $trashPath, $fileInfo, $user, $deletedBy); + } + + public function getInternalOriginalLocation(): string { + return $this->internalOriginalLocation; } public function isRootItem(): bool { diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index 2eb5cf2e0..98a27a240 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -79,7 +79,7 @@ public function listTrashFolder(ITrashItem $trashItem): array { } return new GroupTrashItem( $this, - $trashItem->getOriginalLocation() . '/' . $node->getName(), + $trashItem->getInternalOriginalLocation() . '/' . $node->getName(), $trashItem->getDeletedTime(), $trashItem->getTrashPath() . '/' . $node->getName(), $node, @@ -115,7 +115,7 @@ public function restoreItem(ITrashItem $item) { $trashStorage = $node->getStorage(); /** @var Folder $targetFolder */ $targetFolder = $this->mountProvider->getFolder((int)$folderId); - $originalLocation = $item->getOriginalLocation(); + $originalLocation = $item->getInternalOriginalLocation(); $parent = dirname($originalLocation); if ($parent === '.') { $parent = '';