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 42aa25b commit 4ceed35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/Trash/GroupTrashItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use OCP\IUser;

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

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

0 comments on commit 4ceed35

Please sign in to comment.