From 37eded7e7cda2ab421b573d3b6d9165a4fb9dc9a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 20 Sep 2016 11:29:12 +0200 Subject: [PATCH] Always unlock node after trying to create a share Signed-off-by: Robin Appelman --- apps/files_sharing/lib/API/Share20OCS.php | 4 +++- lib/private/Share20/Share.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 34f73c7ac0..5adfa640c0 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -402,8 +402,10 @@ class Share20OCS extends OCSController { } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); throw new OCSException($e->getHint(), $code); - }catch (\Exception $e) { + } catch (\Exception $e) { throw new OCSForbiddenException($e->getMessage()); + } finally { + $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); } $output = $this->formatShare($share); diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index c565809c07..e3e8482f4e 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -160,7 +160,7 @@ class Share implements \OCP\Share\IShare { $nodes = $userFolder->getById($this->fileId); if (empty($nodes)) { - throw new NotFoundException(); + throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); } $this->node = $nodes[0];