Skip to content

Commit

Permalink
Merge pull request #3362 from nextcloud/original-location-mp
Browse files Browse the repository at this point in the history
fix: include mountpoint in original location for trash items
  • Loading branch information
icewind1991 authored Oct 15, 2024
2 parents 2994e18 + 5beeedd commit a81c18c
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 a81c18c

Please sign in to comment.