-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't count range download in download limit #35324
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -373,11 +373,14 @@ | |||||
$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 @@ | |||||
$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/'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
try { | ||||||
if (!empty($files_list)) { | ||||||
|
@@ -427,11 +432,15 @@ | |||||
&& !isset($downloadStartSecret[32]) | ||||||
&& preg_match('!^[a-zA-Z0-9]+$!', $downloadStartSecret) === 1) { | ||||||
// FIXME: set on the response once we use an actual app framework response | ||||||
setcookie('ocDownloadStarted', $downloadStartSecret, time() + 20, '/'); | ||||||
Check failure on line 435 in apps/files_sharing/lib/Controller/ShareController.php
|
||||||
} | ||||||
|
||||||
$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) { | ||||||
Check failure on line 441 in apps/files_sharing/lib/Controller/ShareController.php
|
||||||
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
|
||||||
$this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD); | ||||||
} | ||||||
|
||||||
$server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ]; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.