diff options
author | Robin Appelman <robin@icewind.nl> | 2018-09-19 19:00:58 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-10-17 14:56:48 +0200 |
commit | d38163e89574e9d2a12be0cdf8f72e1e9bb4b75f (patch) | |
tree | bc07f70d769ed6a1e654b236b51c8499a1bc787c /apps/files_trashbin/lib/Trash/LegacyTrashBackend.php | |
parent | 4adac445dc57d1ccc7f26e21018e1e731e5b1654 (diff) | |
download | nextcloud-server-d38163e89574e9d2a12be0cdf8f72e1e9bb4b75f.tar.gz nextcloud-server-d38163e89574e9d2a12be0cdf8f72e1e9bb4b75f.zip |
fix trashbin previews for modular api
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin/lib/Trash/LegacyTrashBackend.php')
-rw-r--r-- | apps/files_trashbin/lib/Trash/LegacyTrashBackend.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php index 210c84228f7..04e3b284775 100644 --- a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php +++ b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php @@ -27,6 +27,8 @@ use OCA\Files_Trashbin\Helper; use OCA\Files_Trashbin\Storage; use OCA\Files_Trashbin\Trashbin; use OCP\Files\FileInfo; +use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\IUser; @@ -34,6 +36,13 @@ class LegacyTrashBackend implements ITrashBackend { /** @var array */ private $deletedFiles = []; + /** @var IRootFolder */ + private $rootFolder; + + public function __construct(IRootFolder $rootFolder) { + $this->rootFolder = $rootFolder; + } + /** * @param array $items * @param IUser $user @@ -78,7 +87,7 @@ class LegacyTrashBackend implements ITrashBackend { } - public function moveToTrash(IStorage $storage, string $internalPath) { + public function moveToTrash(IStorage $storage, string $internalPath): bool { if (!$storage instanceof Storage) { return false; } @@ -99,4 +108,18 @@ class LegacyTrashBackend implements ITrashBackend { return $result; } + + public function getTrashNodeById(IUser $user, int $fileId) { + try { + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + $trash = $userFolder->getParent()->get('files_trashbin/files'); + $trashFiles = $trash->getById($fileId); + if (!$trashFiles) { + return null; + } + return $trashFiles ? array_pop($trashFiles) : null; + } catch (NotFoundException $e) { + return null; + } + } } |