Skip to content

Commit

Permalink
Ensure download is counted for non video 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 9dcf900 commit 4f84b32
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/files_sharing/lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,14 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
$userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
$originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());

$isVideo = 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);
$isVideo = str_starts_with($node->getMimeType(), 'video/');
}
// Directory share
else {
Expand All @@ -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);
$isVideo = str_starts_with($node->getMimeType(), 'video/');
} else {
try {
if (!empty($files_list)) {
Expand Down Expand Up @@ -431,7 +436,9 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
}

$this->emitAccessShareHook($share);
if (!isset($_SERVER['HTTP_RANGE'])) {

// Ensure download limit is counted unless we are streaming a video
if (!isset($_SERVER['HTTP_RANGE']) || !$isVideo) {
$this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD);
}

Expand Down

0 comments on commit 4f84b32

Please sign in to comment.