Skip to content

Commit

Permalink
Also take in count audio files
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan authored and AndyScherzinger committed Aug 1, 2024
1 parent 4f84b32 commit 3cbfab6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/files_sharing/lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
$userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
$originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());

$isVideo = false;
$isVideoAudio = false;

// Single file share
if ($share->getNode() instanceof \OCP\Files\File) {
$node = $share->getNode();
// Single file download
$this->singleFileDownloaded($share, $node);
$isVideo = str_starts_with($node->getMimeType(), 'video/');
$isVideoAutio = str_starts_with($node->getMimeType(), 'video/') || str_starts_with($node->getMimeType(), 'audio/');
}
// Directory share
else {
Expand All @@ -404,7 +404,7 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
$node = $share->getNode();
// Single file download
$this->singleFileDownloaded($share, $node);
$isVideo = str_starts_with($node->getMimeType(), 'video/');
$isVideoAutio = str_starts_with($node->getMimeType(), 'video/') || str_starts_with($node->getMimeType(), 'audio/');
} else {
try {
if (!empty($files_list)) {
Expand Down Expand Up @@ -437,8 +437,8 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS

$this->emitAccessShareHook($share);

// Ensure download limit is counted unless we are streaming a video
if (!isset($_SERVER['HTTP_RANGE']) || !$isVideo) {
// Ensure download limit is counted unless we are streaming a video or audio file
if (!isset($_SERVER['HTTP_RANGE']) || !$isVideoAudio) {

Check failure on line 441 in apps/files_sharing/lib/Controller/ShareController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

RedundantCondition

apps/files_sharing/lib/Controller/ShareController.php:441:41: RedundantCondition: Operand of type true is always truthy (see https://psalm.dev/122)

Check failure on line 441 in apps/files_sharing/lib/Controller/ShareController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

RedundantCondition

apps/files_sharing/lib/Controller/ShareController.php:441:41: RedundantCondition: Type false for $isVideoAudio is always falsy (see https://psalm.dev/122)

Check failure

Code scanning / Psalm

RedundantCondition Error

Operand of type true is always truthy

Check failure

Code scanning / Psalm

RedundantCondition Error

Type false for $isVideoAudio is always falsy

Check failure on line 441 in apps/files_sharing/lib/Controller/ShareController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

RedundantCondition

apps/files_sharing/lib/Controller/ShareController.php:441:41: RedundantCondition: Operand of type true is always truthy (see https://psalm.dev/122)

Check failure on line 441 in apps/files_sharing/lib/Controller/ShareController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

RedundantCondition

apps/files_sharing/lib/Controller/ShareController.php:441:41: RedundantCondition: Type false for $isVideoAudio is always falsy (see https://psalm.dev/122)
$this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD);
}

Expand Down

0 comments on commit 3cbfab6

Please sign in to comment.