From 4ceed35d53dbcec111c014d7b9c051718f244375 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 | 12 ++++++++---- lib/Trash/TrashBackend.php | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Trash/GroupTrashItem.php b/lib/Trash/GroupTrashItem.php index 04ae4abc7..285fc5a42 100644 --- a/lib/Trash/GroupTrashItem.php +++ b/lib/Trash/GroupTrashItem.php @@ -28,7 +28,7 @@ use OCP\IUser; class GroupTrashItem extends TrashItem { - private string $mountPoint; + private string $internalOriginalLocation; public function __construct( ITrashBackend $backend, @@ -37,10 +37,14 @@ public function __construct( string $trashPath, FileInfo $fileInfo, IUser $user, - string $mountPoint + private string $mountPoint ) { - parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user); - $this->mountPoint = $mountPoint; + $this->internalOriginalLocation = $originalLocation; + parent::__construct($backend, $this->mountPoint . '/' . $originalLocation, $deletedTime, $trashPath, $fileInfo, $user); + } + + public function getInternalOriginalLocation(): string { + return $this->internalOriginalLocation; } public function isRootItem(): bool { diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index 625e98e7a..3ba55adbe 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -101,7 +101,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, @@ -136,7 +136,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 = '';