File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 */
88namespace OC \Share20 ;
99
10+ use OCP \Constants ;
1011use OCP \Files \Cache \ICacheEntry ;
1112use OCP \Files \File ;
1213use OCP \Files \FileInfo ;
@@ -586,6 +587,19 @@ public function getReminderSent(): bool {
586587 return $ this ->reminderSent ;
587588 }
588589
590+ public function canDownload (): bool {
591+ if (($ this ->getPermissions () & Constants::PERMISSION_READ ) === 0 ) {
592+ return false ;
593+ }
594+
595+ $ attributes = $ this ->getAttributes ();
596+ if ($ attributes ?->getAttribute('permissions ' , 'download ' ) === false ) {
597+ return false ;
598+ }
599+
600+ return true ;
601+ }
602+
589603 public function canSeeContent (): bool {
590604 $ shareManager = Server::get (IManager::class);
591605
@@ -595,13 +609,6 @@ public function canSeeContent(): bool {
595609 return true ;
596610 }
597611
598- // No "allow preview" header set, so we must check if
599- // the share has not explicitly disabled download permissions
600- $ attributes = $ this ->getAttributes ();
601- if ($ attributes ?->getAttribute('permissions ' , 'download ' ) === false ) {
602- return false ;
603- }
604-
605- return true ;
612+ return $ this ->canDownload ();
606613 }
607614}
Original file line number Diff line number Diff line change @@ -645,6 +645,15 @@ public function getReminderSent(): bool;
645645 * Check if the current user can see this share files contents.
646646 * This will check the download permissions as well as the global
647647 * admin setting to allow viewing files without downloading.
648+ *
649+ * @since 32.0.0
648650 */
649651 public function canSeeContent (): bool ;
652+
653+ /**
654+ * Check if it is allowed to download this share.
655+ *
656+ * @since 34.0.0
657+ */
658+ public function canDownload (): bool ;
650659}
You can’t perform that action at this time.
0 commit comments