diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index 571efc8c4be..1069d0a706c 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -7,6 +7,7 @@ */ namespace OC\Share20; +use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\File; use OCP\Files\FileInfo; @@ -611,6 +612,19 @@ class Share implements IShare { return $this->reminderSent; } + public function canDownload(): bool { + if (($this->getPermissions() & Constants::PERMISSION_READ) === 0) { + return false; + } + + $attributes = $this->getAttributes(); + if ($attributes?->getAttribute('permissions', 'download') === false) { + return false; + } + + return true; + } + public function canSeeContent(): bool { $shareManager = Server::get(IManager::class); @@ -620,13 +634,6 @@ class Share implements IShare { return true; } - // No "allow preview" header set, so we must check if - // the share has not explicitly disabled download permissions - $attributes = $this->getAttributes(); - if ($attributes?->getAttribute('permissions', 'download') === false) { - return false; - } - - return true; + return $this->canDownload(); } } diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index a1bdb01fcd2..4436470b4e8 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -652,6 +652,15 @@ interface IShare { * Check if the current user can see this share files contents. * This will check the download permissions as well as the global * admin setting to allow viewing files without downloading. + * + * @since 32.0.0 */ public function canSeeContent(): bool; + + /** + * Check if it is allowed to download this share. + * + * @since 34.0.0 + */ + public function canDownload(): bool; }