Skip to content

Commit afa37d3

Browse files
committed
Fix related logic
1 parent 6123bad commit afa37d3

File tree

5 files changed

+48
-24
lines changed

5 files changed

+48
-24
lines changed

apps/dav/lib/connector/sabre/node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function getSharePermissions() {
224224

225225
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
226226
/** @var \OC\Files\Storage\Shared $storage */
227-
$permissions = (int)$storage->getShare()['permissions'];
227+
$permissions = (int)$storage->getShare()->getPermissions();
228228
} else {
229229
$permissions = $storage->getPermissions($path);
230230
}

lib/private/Share20/Manager.php

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

lib/private/files/config/usermountcache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function registerMounts(IUser $user, array $mounts) {
8282
$newMounts = array_map(function (IMountPoint $mount) use ($user) {
8383
$storage = $mount->getStorage();
8484
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
85-
$rootId = (int)$storage->getShare()['file_source'];
85+
$rootId = (int)$storage->getShare()->getNodeId();
8686
} else {
8787
$rootId = (int)$storage->getCache()->getId('');
8888
}

lib/private/files/storage/wrapper/jail.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct($arguments) {
4747
$this->rootPath = $arguments['root'];
4848
}
4949

50-
protected function getSourcePath($path) {
50+
public function getSourcePath($path) {
5151
if ($path === '') {
5252
return $this->rootPath;
5353
} else {
@@ -415,6 +415,14 @@ public function getETag($path) {
415415
return $this->storage->getETag($this->getSourcePath($path));
416416
}
417417

418+
/**
419+
* @param string $path
420+
* @return array
421+
*/
422+
public function getMetaData($path) {
423+
return $this->storage->getMetaData($this->getSourcePath($path));
424+
}
425+
418426
/**
419427
* @param string $path
420428
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
@@ -442,4 +450,9 @@ public function releaseLock($path, $type, ILockingProvider $provider) {
442450
public function changeLock($path, $type, ILockingProvider $provider) {
443451
$this->storage->changeLock($this->getSourcePath($path), $type, $provider);
444452
}
453+
454+
public function resolvePath($path) {
455+
$path = $this->getSourcePath($path);
456+
return \OC\Files\Filesystem::resolvePath($path);
457+
}
445458
}

lib/private/helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public static function getStorageInfo($path, $rootInfo = null) {
628628
/** @var \OC\Files\Storage\Wrapper\Quota $storage */
629629
$quota = $sourceStorage->getQuota();
630630
}
631-
$free = $storage->free_space('');
631+
$free = $sourceStorage->free_space('');
632632
if ($free >= 0) {
633633
$total = $free + $used;
634634
} else {

0 commit comments

Comments
 (0)