From caec3a8ceec1d63ffbb8bc4bbab2c665501a8757 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 30 Mar 2021 12:59:40 +0200 Subject: [PATCH] gracefully handle deleteFromSelf when share is already gone - handling race conditions Signed-off-by: Arthur Schiwon --- lib/private/Share20/DefaultShareProvider.php | 3 ++- tests/lib/Share20/DefaultShareProviderTest.php | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index cf05e9bfbc398..00ef7e2426b9b 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -470,7 +470,8 @@ public function deleteFromSelf(IShare $share, $recipient) { } if (!$group->inGroup($user)) { - throw new ProviderException('Recipient not in receiving group'); + // nothing left to do + return; } // Try to fetch user specific share diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index f6ce4894dbbc5..40626bdb57134 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -1558,9 +1558,6 @@ public function testDeleteFromSelfGroupAlreadyCustomShare() { public function testDeleteFromSelfGroupUserNotInGroup() { - $this->expectException(\OC\Share20\Exception\ProviderException::class); - $this->expectExceptionMessage('Recipient not in receiving group'); - $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([