summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api/share20ocs.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-03-09 09:11:41 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-04-30 10:32:35 +0200
commit62bc53143e7f6b13fad1d0bb9e899a3715d55e49 (patch)
tree67cffd9ed60fb2dba622e00af69147dc0612220c /apps/files_sharing/api/share20ocs.php
parent023c8b0eacc243b2dd4763e6086fc87ce8b76126 (diff)
downloadnextcloud-server-62bc53143e7f6b13fad1d0bb9e899a3715d55e49.tar.gz
nextcloud-server-62bc53143e7f6b13fad1d0bb9e899a3715d55e49.zip
Add locking to modifying operation of the OCS Share API
Fixes #17243 This is done in the OCS Share API instead of the share manager since we want lazy shares in general. However when doing modifying calls via the OCS Share API it is fine to force real nodes. * Updated unit tests to work with logging
Diffstat (limited to 'apps/files_sharing/api/share20ocs.php')
-rw-r--r--apps/files_sharing/api/share20ocs.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 68098530017..8b2c413b6fc 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -28,6 +28,7 @@ use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Files\IRootFolder;
+use OCP\Lock\LockedException;
use OCP\Share;
use OCP\Share\IManager;
@@ -205,12 +206,20 @@ class Share20OCS {
return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist'));
}
+ try {
+ $share->getNode()->lock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ } catch (LockedException $e) {
+ return new \OC_OCS_Result(null, 404, 'could not delete share');
+ }
+
if (!$this->canAccessShare($share)) {
return new \OC_OCS_Result(null, 404, $this->l->t('Could not delete share'));
}
$this->shareManager->deleteShare($share);
+ $share->getNode()->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
return new \OC_OCS_Result();
}
@@ -238,6 +247,7 @@ class Share20OCS {
}
$share->setNode($path);
+ $share->getNode()->lock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
// Parse permissions (if available)
$permissions = $this->request->getParam('permissions', null);
@@ -368,8 +378,11 @@ class Share20OCS {
return new \OC_OCS_Result(null, 403, $e->getMessage());
}
- $share = $this->formatShare($share);
- return new \OC_OCS_Result($share);
+ $output = $this->formatShare($share);
+
+ $share->getNode()->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
+ return new \OC_OCS_Result($output);
}
/**
@@ -512,6 +525,8 @@ class Share20OCS {
return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist'));
}
+ $share->getNode()->lock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
if (!$this->canAccessShare($share)) {
return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist'));
}
@@ -611,6 +626,8 @@ class Share20OCS {
return new \OC_OCS_Result(null, 400, $e->getMessage());
}
+ $share->getNode()->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
return new \OC_OCS_Result($this->formatShare($share));
}