From b1fe148a7116161a6b8f7a3537a7b5cb2212f9bc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Feb 2020 16:25:09 +0100 Subject: [PATCH 1/2] Allow single file downloads so the video player works again Signed-off-by: Joas Schilling --- .../lib/Controller/ShareController.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 11cab9cfce..6d9697a38e 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -528,10 +528,6 @@ class ShareController extends AuthPublicShareController { throw new NotFoundException(); } - if ($share->getHideDownload()) { - return new NotFoundResponse(); - } - $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath()); @@ -561,11 +557,17 @@ class ShareController extends AuthPublicShareController { if ($node instanceof \OCP\Files\File) { // Single file download $this->singleFileDownloaded($share, $share->getNode()); - } else if (!empty($files_list)) { - $this->fileListDownloaded($share, $files_list, $node); } else { - // The folder is downloaded - $this->singleFileDownloaded($share, $share->getNode()); + if ($share->getHideDownload()) { + return new NotFoundResponse(); + } + + if (!empty($files_list)) { + $this->fileListDownloaded($share, $files_list, $node); + } else { + // The folder is downloaded + $this->singleFileDownloaded($share, $share->getNode()); + } } } From 4f397381bae4c1bfe4845d13908b47c017f04825 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 19 Mar 2020 15:14:00 +0100 Subject: [PATCH 2/2] Allow the video player on the hide download Signed-off-by: Joas Schilling --- .../lib/Controller/ShareController.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 6d9697a38e..411b1a58c7 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -46,6 +46,7 @@ use OCP\AppFramework\Http\Template\ExternalShareMenuAction; use OCP\AppFramework\Http\Template\LinkMenuAction; use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\Defaults; +use OCP\Files\Folder; use OCP\IL10N; use OCP\Template; use OCP\Share; @@ -558,16 +559,16 @@ class ShareController extends AuthPublicShareController { // Single file download $this->singleFileDownloaded($share, $share->getNode()); } else { - if ($share->getHideDownload()) { + try { + if (!empty($files_list)) { + $this->fileListDownloaded($share, $files_list, $node); + } else { + // The folder is downloaded + $this->singleFileDownloaded($share, $share->getNode()); + } + } catch (NotFoundException $e) { return new NotFoundResponse(); } - - if (!empty($files_list)) { - $this->fileListDownloaded($share, $files_list, $node); - } else { - // The folder is downloaded - $this->singleFileDownloaded($share, $share->getNode()); - } } } @@ -619,8 +620,13 @@ class ShareController extends AuthPublicShareController { * @param Share\IShare $share * @param array $files_list * @param \OCP\Files\Folder $node + * @throws NotFoundException when trying to download a folder or multiple files of a "hide download" share */ protected function fileListDownloaded(Share\IShare $share, array $files_list, \OCP\Files\Folder $node) { + if ($share->getHideDownload() && count($files_list) > 1) { + throw new NotFoundException('Downloading more than 1 file'); + } + foreach ($files_list as $file) { $subNode = $node->get($file); $this->singleFileDownloaded($share, $subNode); @@ -632,8 +638,12 @@ class ShareController extends AuthPublicShareController { * create activity if a single file was downloaded from a link share * * @param Share\IShare $share + * @throws NotFoundException when trying to download a folder of a "hide download" share */ protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) { + if ($share->getHideDownload() && $node instanceof Folder) { + throw new NotFoundException('Downloading a folder'); + } $fileId = $node->getId();