From 5eb72a8a57210b44668fc1677ac3e057444665be Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 10 May 2018 16:03:28 +0200 Subject: [PATCH] Support fileid propfind on trash endpoint Fixes #9416 In order to support previews on mobile clients they will need the fileid of files in the trashbin. Signed-off-by: Roeland Jago Douma --- apps/files_trashbin/lib/Helper.php | 4 ++-- apps/files_trashbin/lib/Sabre/ITrash.php | 2 ++ apps/files_trashbin/lib/Sabre/PropfindPlugin.php | 4 ++++ apps/files_trashbin/lib/Sabre/TrashFile.php | 6 ++++++ apps/files_trashbin/lib/Sabre/TrashFolder.php | 4 ++++ apps/files_trashbin/lib/Sabre/TrashFolderFile.php | 4 ++++ apps/files_trashbin/lib/Sabre/TrashFolderFolder.php | 4 ++++ 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/files_trashbin/lib/Helper.php b/apps/files_trashbin/lib/Helper.php index 65407b8a56..01a4fd231e 100644 --- a/apps/files_trashbin/lib/Helper.php +++ b/apps/files_trashbin/lib/Helper.php @@ -62,7 +62,6 @@ class Helper { $dirContent = $storage->getCache()->getFolderContents($mount->getInternalPath($view->getAbsolutePath($dir))); foreach ($dirContent as $entry) { $entryName = $entry->getName(); - $id = $entry->getId(); $name = $entryName; if ($dir === '' || $dir === '/') { $pathparts = pathinfo($entryName); @@ -91,7 +90,8 @@ class Helper { 'directory' => ($dir === '/') ? '' : $dir, 'size' => $entry->getSize(), 'etag' => '', - 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE + 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE, + 'fileid' => $entry->getId(), ); if ($originalPath) { if ($originalPath !== '.') { diff --git a/apps/files_trashbin/lib/Sabre/ITrash.php b/apps/files_trashbin/lib/Sabre/ITrash.php index 43e59e03bc..6db9bccf0a 100644 --- a/apps/files_trashbin/lib/Sabre/ITrash.php +++ b/apps/files_trashbin/lib/Sabre/ITrash.php @@ -33,4 +33,6 @@ interface ITrash { public function getDeletionTime(): int; public function getSize(); + + public function getFileId(): int; } diff --git a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php index 078f85da8f..492035304b 100644 --- a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php +++ b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php @@ -69,6 +69,10 @@ class PropfindPlugin extends ServerPlugin { $propFind->handle(FilesPlugin::SIZE_PROPERTYNAME, function () use ($node) { return $node->getSize(); }); + + $propFind->handle(FilesPlugin::FILEID_PROPERTYNAME, function () use ($node) { + return $node->getFileId(); + }); } } diff --git a/apps/files_trashbin/lib/Sabre/TrashFile.php b/apps/files_trashbin/lib/Sabre/TrashFile.php index e4c67cbfb3..eba9eee641 100644 --- a/apps/files_trashbin/lib/Sabre/TrashFile.php +++ b/apps/files_trashbin/lib/Sabre/TrashFile.php @@ -90,4 +90,10 @@ class TrashFile implements IFile, ITrash { public function getDeletionTime(): int { return $this->getLastModified(); } + + public function getFileId(): int { + return $this->data->getId(); + } + + } diff --git a/apps/files_trashbin/lib/Sabre/TrashFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolder.php index 76ccb2b0df..6b7d71b80e 100644 --- a/apps/files_trashbin/lib/Sabre/TrashFolder.php +++ b/apps/files_trashbin/lib/Sabre/TrashFolder.php @@ -123,4 +123,8 @@ class TrashFolder implements ICollection, ITrash { public function getSize(): int { return $this->data->getSize(); } + + public function getFileId(): int { + return $this->data->getId(); + } } diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php index 9dd2f7b3ef..921c98b02f 100644 --- a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php +++ b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php @@ -101,4 +101,8 @@ class TrashFolderFile implements IFile, ITrash { public function getDeletionTime(): int { return $this->getLastModified(); } + + public function getFileId(): int { + return $this->data->getId(); + } } diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php index de0725ab92..2fe75479c1 100644 --- a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php +++ b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php @@ -136,4 +136,8 @@ class TrashFolderFolder implements ICollection, ITrash { public function getSize(): int { return $this->data->getSize(); } + + public function getFileId(): int { + return $this->data->getId(); + } }