diff options
author | Joas Schilling <coding@schilljs.com> | 2020-03-19 17:14:00 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-03-19 17:14:00 +0300 |
commit | 6edb93fc4a3e7cc143f29f49556a19563dd87c80 (patch) | |
tree | 48cd77fe759c5ea4814c7de47ac8f5c414e815c2 /apps/files_sharing/lib | |
parent | 4a21ce27ffd3883dd2c08d45b0258511469aa74b (diff) |
Allow the video player on the hide download
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 3feb98f7f02..620aaf42c69 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -55,6 +55,7 @@ use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\AppFramework\Http\Template\SimpleMenuAction; use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\IConfig; @@ -582,16 +583,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()); - } } } @@ -643,8 +644,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); @@ -656,8 +662,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(); |