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 <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Dec 11, 2024
1 parent 5296672 commit d4b068d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions lib/Trash/GroupTrashItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use OCP\IUser;

class GroupTrashItem extends TrashItem {
private string $mountPoint;
private string $internalOriginalLocation;

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

0 comments on commit d4b068d

Please sign in to comment.