Skip to content
Snippets Groups Projects
Unverified Commit 20852fd8 authored by Björn Schießle's avatar Björn Schießle
Browse files

remove reshares and the mapping in the federated_reshares table on unshare from self

parent bc8f659d
No related branches found
No related tags found
No related merge requests found
...@@ -325,6 +325,10 @@ class Manager { ...@@ -325,6 +325,10 @@ class Manager {
} }
public function removeShare($mountPoint) { public function removeShare($mountPoint) {
$mountPointObj = $this->mountManager->find($mountPoint);
$id = $mountPointObj->getStorage()->getCache()->getId();
$mountPoint = $this->stripPath($mountPoint); $mountPoint = $this->stripPath($mountPoint);
$hash = md5($mountPoint); $hash = md5($mountPoint);
...@@ -345,7 +349,36 @@ class Manager { ...@@ -345,7 +349,36 @@ class Manager {
WHERE `mountpoint_hash` = ? WHERE `mountpoint_hash` = ?
AND `user` = ? 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();
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment