Skip to content
Snippets Groups Projects
Commit 0616eb40 authored by Robin Appelman's avatar Robin Appelman
Browse files

Fix multiple users having the same external share mountpoint

parent 5b1b6572
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,10 @@
<index>
<name>sh_external_mp</name>
<unique>true</unique>
<field>
<name>user</name>
<sorting>ascending</sorting>
</field>
<field>
<name>mountpoint_hash</name>
<sorting>ascending</sorting>
......
0.5.1
0.5.2
......@@ -117,22 +117,24 @@ class Manager {
* @return bool
*/
public function setMountPoint($source, $target) {
$user = $this->userSession->getUser();
$source = $this->stripPath($source);
$target = $this->stripPath($target);
$sourceHash = md5($source);
$targetHash = md5($target);
$query = $this->connection->prepare('UPDATE *PREFIX*share_external SET
`mountpoint` = ?, `mountpoint_hash` = ? WHERE `mountpoint_hash` = ?');
$result = (bool)$query->execute(array($target, $targetHash, $sourceHash));
`mountpoint` = ?, `mountpoint_hash` = ? WHERE `mountpoint_hash` = ? AND `user` = ?');
$result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $user->getUID()));
return $result;
}
public function removeShare($mountPoint) {
$user = $this->userSession->getUser();
$mountPoint = $this->stripPath($mountPoint);
$hash = md5($mountPoint);
$query = $this->connection->prepare('DELETE FROM *PREFIX*share_external WHERE `mountpoint_hash` = ?');
return (bool)$query->execute(array($hash));
$query = $this->connection->prepare('DELETE FROM *PREFIX*share_external WHERE `mountpoint_hash` = ? AND `user` = ?');
return (bool)$query->execute(array($hash, $user->getUID()));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment