diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index eef2f5f32bc75..5b0b082537a0c 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -373,11 +373,14 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath()); + $isVideoAudio = false; // Single file share if ($share->getNode() instanceof \OCP\Files\File) { + $node = $share->getNode(); // Single file download - $this->singleFileDownloaded($share, $share->getNode()); + $this->singleFileDownloaded($share, $node); + $isVideoAutio = str_starts_with($node->getMimeType(), 'video/') || str_starts_with($node->getMimeType(), 'audio/'); } // Directory share else { @@ -398,8 +401,10 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS $originalSharePath = $userFolder->getRelativePath($node->getPath()); if ($node instanceof \OCP\Files\File) { + $node = $share->getNode(); // Single file download - $this->singleFileDownloaded($share, $share->getNode()); + $this->singleFileDownloaded($share, $node); + $isVideoAutio = str_starts_with($node->getMimeType(), 'video/') || str_starts_with($node->getMimeType(), 'audio/'); } else { try { if (!empty($files_list)) { @@ -431,7 +436,11 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS } $this->emitAccessShareHook($share); - $this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD); + + // Ensure download limit is counted unless we are streaming a video or audio file + if (!isset($_SERVER['HTTP_RANGE']) || !$isVideoAudio) { + $this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD); + } $server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ];