summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2016-05-19 17:22:12 +0200
committerBjörn Schießle <schiessle@owncloud.com>2016-05-20 21:15:16 +0200
commit20852fd8c071b949962406d7ffb3b6e173eb171b (patch)
tree1cdba7f5b377c3d125e841f2263046d763deb9de /apps
parentbc8f659d06826a0c16a1bbe1fb9ce932fd6baa5f (diff)
downloadnextcloud-server-20852fd8c071b949962406d7ffb3b6e173eb171b.tar.gz
nextcloud-server-20852fd8c071b949962406d7ffb3b6e173eb171b.zip
remove reshares and the mapping in the federated_reshares table on unshare from self
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/external/manager.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php
index 22525b4e061..5b7a13f1eb1 100644
--- a/apps/files_sharing/lib/external/manager.php
+++ b/apps/files_sharing/lib/external/manager.php
@@ -325,6 +325,10 @@ class Manager {
}
public function removeShare($mountPoint) {
+
+ $mountPointObj = $this->mountManager->find($mountPoint);
+ $id = $mountPointObj->getStorage()->getCache()->getId();
+
$mountPoint = $this->stripPath($mountPoint);
$hash = md5($mountPoint);
@@ -345,7 +349,36 @@ class Manager {
WHERE `mountpoint_hash` = ?
AND `user` = ?
');
- return (bool)$query->execute(array($hash, $this->uid));
+ $result = (bool)$query->execute(array($hash, $this->uid));
+
+ if($result) {
+ $this->removeReShares($id);
+ }
+
+ return $result;
+ }
+
+ /**
+ * remove re-shares from share table and mapping in the federated_reshares table
+ *
+ * @param $mountPointId
+ */
+ protected function removeReShares($mountPointId) {
+ $selectQuery = $this->connection->getQueryBuilder();
+ $query = $this->connection->getQueryBuilder();
+ $selectQuery->select('id')->from('share')
+ ->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId)));
+ $select = $selectQuery->getSQL();
+
+
+ $query->delete('federated_reshares')
+ ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
+ $query->execute();
+
+ $deleteReShares = $this->connection->getQueryBuilder();
+ $deleteReShares->delete('share')
+ ->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId)));
+ $deleteReShares->execute();
}
/**