Skip to content

Commit

Permalink
Merge pull request #3365 from nextcloud/backport/3362/stable30
Browse files Browse the repository at this point in the history
[stable30] fix: include mountpoint in original location for trash items
  • Loading branch information
icewind1991 authored Dec 11, 2024
2 parents 5296672 + d4b068d commit 7771396
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 7771396

Please sign in to comment.