From 5beeedd64a15ce4335b8445e656ec049e1e7b04e 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 | 9 ++++++++- lib/Trash/TrashBackend.php | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Trash/GroupTrashItem.php b/lib/Trash/GroupTrashItem.php index 3e24f8375..fe4645988 100644 --- a/lib/Trash/GroupTrashItem.php +++ b/lib/Trash/GroupTrashItem.php @@ -14,6 +14,8 @@ use OCP\IUser; class GroupTrashItem extends TrashItem { + private string $internalOriginalLocation; + public function __construct( ITrashBackend $backend, string $originalLocation, @@ -24,7 +26,12 @@ public function __construct( private string $mountPoint, ?IUser $deletedBy, ) { - parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user, $deletedBy); + $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 10a9adf93..7912135a6 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -80,7 +80,7 @@ public function listTrashFolder(ITrashItem $folder): array { return new GroupTrashItem( $this, - $folder->getOriginalLocation() . '/' . $node->getName(), + $folder->getInternalOriginalLocation() . '/' . $node->getName(), $folder->getDeletedTime(), $folder->getTrashPath() . '/' . $node->getName(), $node, @@ -118,7 +118,7 @@ public function restoreItem(ITrashItem $item): void { $trashStorage = $node->getStorage(); /** @var Folder $targetFolder */ $targetFolder = $this->mountProvider->getFolder((int)$folderId); - $originalLocation = $item->getOriginalLocation(); + $originalLocation = $item->getInternalOriginalLocation(); $parent = dirname($originalLocation); if ($parent === '.') { $parent = '';