@@ -237,6 +237,17 @@ protected function generalCreateChecks(\OCP\Share\IShare $share) {
237237 if (($ share ->getPermissions () & \OCP \Constants::PERMISSION_READ ) === 0 ) {
238238 throw new \InvalidArgumentException ('Shares need at least read permissions ' );
239239 }
240+
241+ if ($ share ->getNode () instanceof \OCP \Files \File) {
242+ if ($ share ->getPermissions () & \OCP \Constants::PERMISSION_DELETE ) {
243+ $ message_t = $ this ->l ->t ('Files can \'t be shared with delete permissions ' );
244+ throw new GenericShareException ($ message_t );
245+ }
246+ if ($ share ->getPermissions () & \OCP \Constants::PERMISSION_CREATE ) {
247+ $ message_t = $ this ->l ->t ('Files can \'t be shared with create permissions ' );
248+ throw new GenericShareException ($ message_t );
249+ }
250+ }
240251 }
241252
242253 /**
@@ -505,6 +516,24 @@ public function createShare(\OCP\Share\IShare $share) {
505516
506517 $ this ->generalCreateChecks ($ share );
507518
519+ // Verify if there are any issues with the path
520+ $ this ->pathCreateChecks ($ share ->getNode ());
521+
522+ /*
523+ * On creation of a share the owner is always the owner of the path
524+ * Except for mounted federated shares.
525+ */
526+ $ storage = $ share ->getNode ()->getStorage ();
527+ if ($ storage ->instanceOfStorage ('OCA\Files_Sharing\External\Storage ' )) {
528+ $ parent = $ share ->getNode ()->getParent ();
529+ while ($ parent ->getStorage ()->instanceOfStorage ('OCA\Files_Sharing\External\Storage ' )) {
530+ $ parent = $ parent ->getParent ();
531+ }
532+ $ share ->setShareOwner ($ parent ->getOwner ()->getUID ());
533+ } else {
534+ $ share ->setShareOwner ($ share ->getNode ()->getOwner ()->getUID ());
535+ }
536+
508537 //Verify share type
509538 if ($ share ->getShareType () === \OCP \Share::SHARE_TYPE_USER ) {
510539 $ this ->userCreateChecks ($ share );
@@ -538,24 +567,6 @@ public function createShare(\OCP\Share\IShare $share) {
538567 }
539568 }
540569
541- // Verify if there are any issues with the path
542- $ this ->pathCreateChecks ($ share ->getNode ());
543-
544- /*
545- * On creation of a share the owner is always the owner of the path
546- * Except for mounted federated shares.
547- */
548- $ storage = $ share ->getNode ()->getStorage ();
549- if ($ storage ->instanceOfStorage ('OCA\Files_Sharing\External\Storage ' )) {
550- $ parent = $ share ->getNode ()->getParent ();
551- while ($ parent ->getStorage ()->instanceOfStorage ('OCA\Files_Sharing\External\Storage ' )) {
552- $ parent = $ parent ->getParent ();
553- }
554- $ share ->setShareOwner ($ parent ->getOwner ()->getUID ());
555- } else {
556- $ share ->setShareOwner ($ share ->getNode ()->getOwner ()->getUID ());
557- }
558-
559570 // Cannot share with the owner
560571 if ($ share ->getShareType () === \OCP \Share::SHARE_TYPE_USER &&
561572 $ share ->getSharedWith () === $ share ->getShareOwner ()) {
@@ -818,7 +829,7 @@ public function deleteShare(\OCP\Share\IShare $share) {
818829 * @param string $recipientId
819830 */
820831 public function deleteFromSelf (\OCP \Share \IShare $ share , $ recipientId ) {
821- list ($ providerId , ) = $ this ->splitFullId ($ share ->getId ());
832+ list ($ providerId , ) = $ this ->splitFullId ($ share ->getFullId ());
822833 $ provider = $ this ->factory ->getProvider ($ providerId );
823834
824835 $ provider ->deleteFromSelf ($ share , $ recipientId );
@@ -844,7 +855,7 @@ public function moveShare(\OCP\Share\IShare $share, $recipientId) {
844855 }
845856 }
846857
847- list ($ providerId , ) = $ this ->splitFullId ($ share ->getId ());
858+ list ($ providerId , ) = $ this ->splitFullId ($ share ->getFullId ());
848859 $ provider = $ this ->factory ->getProvider ($ providerId );
849860
850861 $ provider ->move ($ share , $ recipientId );
0 commit comments