unshare from self

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Bjoern Schiessle 2018-06-29 17:47:36 +02:00
parent f5a816262c
commit 7d2add622e
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
1 changed files with 15 additions and 10 deletions

View File

@ -515,28 +515,33 @@ class Manager {
$hash = md5($mountPoint);
$getShare = $this->connection->prepare('
SELECT `remote`, `share_token`, `remote_id`
SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id`
FROM `*PREFIX*share_external`
WHERE `mountpoint_hash` = ? AND `user` = ?');
$result = $getShare->execute(array($hash, $this->uid));
if ($result) {
$share = $getShare->fetch();
$getShare->closeCursor();
if ($result && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
try {
$share = $getShare->fetch();
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
} catch (\Exception $e) {
// if we fail to notify the remote (probably cause the remote is down)
// we still want the share to be gone to prevent undeletable remotes
}
}
$getShare->closeCursor();
$query = $this->connection->prepare('
$query = $this->connection->prepare('
DELETE FROM `*PREFIX*share_external`
WHERE `mountpoint_hash` = ?
AND `user` = ?
');
$result = (bool)$query->execute(array($hash, $this->uid));
WHERE `id` = ?
');
$result = (bool)$query->execute(array((int)$share['id']));
} else if ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
$query = $this->connection->prepare('
UPDATE `*PREFIX*share_external`
SET `accepted` = ?
WHERE `id` = ?');
$result = (bool)$query->execute(array(0, (int)$share['id']));
}
if($result) {
$this->removeReShares($id);