summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php15
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php8
2 files changed, 15 insertions, 8 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 270bf86daf7..6481abe32e2 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -222,6 +222,8 @@ class FederatedShareProvider implements IShareProvider {
$token
);
+ $failure = false;
+
try {
$sharedByFederatedId = $share->getSharedBy();
if ($this->userManager->userExists($sharedByFederatedId)) {
@@ -239,17 +241,22 @@ class FederatedShareProvider implements IShareProvider {
);
if ($send === false) {
- $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.',
- [$share->getNode()->getName(), $share->getSharedWith()]);
- throw new \Exception($message_t);
+ $failure = true;
}
} catch (\Exception $e) {
$this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')');
+ $failure = true;
+ }
+
+ if($failure) {
$this->removeShareFromTableById($shareId);
- throw $e;
+ $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.',
+ [$share->getNode()->getName(), $share->getSharedWith()]);
+ throw new \Exception($message_t);
}
return $shareId;
+
}
/**
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index 92f6ac5e996..874d4b48a5c 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -227,7 +227,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
$share = $this->provider->create($share);
$this->fail();
} catch (\Exception $e) {
- $this->assertEquals('Sharing myFile failed, could not find user@server.com, maybe the server is currently unreachable.', $e->getMessage());
+ $this->assertEquals('Sharing myFile failed, could not find user@server.com, maybe the server is currently unreachable or uses a self-signed certificate.', $e->getMessage());
}
$qb = $this->connection->getQueryBuilder();
@@ -283,7 +283,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
$share = $this->provider->create($share);
$this->fail();
} catch (\Exception $e) {
- $this->assertEquals('dummy', $e->getMessage());
+ $this->assertEquals('Sharing myFile failed, could not find user@server.com, maybe the server is currently unreachable or uses a self-signed certificate.', $e->getMessage());
}
$qb = $this->connection->getQueryBuilder();
@@ -707,8 +707,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$userManager = \OC::$server->getUserManager();
$rootFolder = \OC::$server->getRootFolder();
- $u1 = $userManager->createUser('testFed', 'test');
- $u2 = $userManager->createUser('testFed2', 'test');
+ $u1 = $userManager->createUser('testFed', md5(time()));
+ $u2 = $userManager->createUser('testFed2', md5(time()));
$folder1 = $rootFolder->getUserFolder($u1->getUID())->newFolder('foo');
$file1 = $folder1->newFile('bar1');