Skip to content

Commit 4f39738

Browse files
committed
Allow the video player on the hide download
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent b1fe148 commit 4f39738

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

apps/files_sharing/lib/Controller/ShareController.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use OCP\AppFramework\Http\Template\LinkMenuAction;
4747
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
4848
use OCP\Defaults;
49+
use OCP\Files\Folder;
4950
use OCP\IL10N;
5051
use OCP\Template;
5152
use OCP\Share;
@@ -558,16 +559,16 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
558559
// Single file download
559560
$this->singleFileDownloaded($share, $share->getNode());
560561
} else {
561-
if ($share->getHideDownload()) {
562+
try {
563+
if (!empty($files_list)) {
564+
$this->fileListDownloaded($share, $files_list, $node);
565+
} else {
566+
// The folder is downloaded
567+
$this->singleFileDownloaded($share, $share->getNode());
568+
}
569+
} catch (NotFoundException $e) {
562570
return new NotFoundResponse();
563571
}
564-
565-
if (!empty($files_list)) {
566-
$this->fileListDownloaded($share, $files_list, $node);
567-
} else {
568-
// The folder is downloaded
569-
$this->singleFileDownloaded($share, $share->getNode());
570-
}
571572
}
572573
}
573574

@@ -619,8 +620,13 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
619620
* @param Share\IShare $share
620621
* @param array $files_list
621622
* @param \OCP\Files\Folder $node
623+
* @throws NotFoundException when trying to download a folder or multiple files of a "hide download" share
622624
*/
623625
protected function fileListDownloaded(Share\IShare $share, array $files_list, \OCP\Files\Folder $node) {
626+
if ($share->getHideDownload() && count($files_list) > 1) {
627+
throw new NotFoundException('Downloading more than 1 file');
628+
}
629+
624630
foreach ($files_list as $file) {
625631
$subNode = $node->get($file);
626632
$this->singleFileDownloaded($share, $subNode);
@@ -632,8 +638,12 @@ protected function fileListDownloaded(Share\IShare $share, array $files_list, \O
632638
* create activity if a single file was downloaded from a link share
633639
*
634640
* @param Share\IShare $share
641+
* @throws NotFoundException when trying to download a folder of a "hide download" share
635642
*/
636643
protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
644+
if ($share->getHideDownload() && $node instanceof Folder) {
645+
throw new NotFoundException('Downloading a folder');
646+
}
637647

638648
$fileId = $node->getId();
639649

0 commit comments

Comments
 (0)