From 083cfd3898bc1d97e175654dd2cf41971f54f7dc Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 3 Jan 2024 14:37:31 +0100 Subject: [PATCH] fix downloading trashbin items Signed-off-by: Robin Appelman --- lib/Trash/GroupTrashItem.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/Trash/GroupTrashItem.php b/lib/Trash/GroupTrashItem.php index 48a7dcc84..04ae4abc7 100644 --- a/lib/Trash/GroupTrashItem.php +++ b/lib/Trash/GroupTrashItem.php @@ -21,6 +21,7 @@ namespace OCA\GroupFolders\Trash; +use OC\Files\Storage\Wrapper\Jail; use OCA\Files_Trashbin\Trash\ITrashBackend; use OCA\Files_Trashbin\Trash\TrashItem; use OCP\Files\FileInfo; @@ -53,4 +54,26 @@ public function getGroupFolderMountPoint(): string { public function getTitle(): string { return $this->getGroupFolderMountPoint() . '/' . $this->getOriginalLocation(); } + + public function getStorage() { + // get the unjailed storage, since the trash item is outside the jail + // (the internal path is also unjailed) + $groupFolderStorage = parent::getStorage(); + if ($groupFolderStorage->instanceOfStorage(Jail::class)) { + /** @var Jail $groupFolderStorage */ + return $groupFolderStorage->getUnjailedStorage(); + } + return $groupFolderStorage; + } + + public function getMtime() { + // trashbin is currently (incorrectly) assuming these to be the same + return $this->getDeletedTime(); + } + + public function getInternalPath() { + // trashbin expects the path without the deletion timestamp + $path = parent::getInternalPath(); + return rtrim($path, '.d' . $this->getDeletedTime()); + } }