Skip to content

Commit

Permalink
fix: include mountpoint in original location for trash items
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Oct 15, 2024
1 parent 3aea7a2 commit 5beeedd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/Trash/GroupTrashItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use OCP\IUser;

class GroupTrashItem extends TrashItem {
private string $internalOriginalLocation;

public function __construct(
ITrashBackend $backend,
string $originalLocation,
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit 5beeedd

Please sign in to comment.