summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/sharedstorage.php43
1 files changed, 36 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 7ce9dd58b41..25e6c0abd28 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -317,14 +317,27 @@ class Shared extends \OC\Files\Storage\Common {
$relTargetPath = $this->stripUserFilesPath($targetPath);
- // rename mount point
- $query = \OC_DB::prepare(
- 'Update `*PREFIX*share`
- SET `file_target` = ?
- WHERE `id` = ?'
- );
+ // if the user renames a mount point from a group share we need to create a new db entry
+ // for the unique name
+ if ($this->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && $this->uniqueNameSet() === false) {
+ $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,'
+ .' `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,'
+ .' `file_target`, `token`, `parent`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)');
+ $arguments = array($this->share['item_type'], $this->share['item_source'], $this->share['item_target'],
+ 2, \OCP\User::getUser(), $this->share['uid_owner'], $this->share['permissions'], $this->share['stime'], $this->share['file_source'],
+ $relTargetPath, $this->share['token'], $this->share['id']);
- $result = $query->execute(array($relTargetPath, $this->getShareId()));
+ } else {
+ // rename mount point
+ $query = \OC_DB::prepare(
+ 'Update `*PREFIX*share`
+ SET `file_target` = ?
+ WHERE `id` = ?'
+ );
+ $arguments = array($relTargetPath, $this->getShareId());
+ }
+
+ $result = $query->execute($arguments);
if ($result) {
// update the mount manager with the new paths
@@ -333,6 +346,7 @@ class Shared extends \OC\Files\Storage\Common {
$mount->setMountPoint($targetPath . '/');
$mountManager->addMount($mount);
$mountManager->removeMount($sourcePath . '/');
+ $this->setUniqueName();
} else {
\OCP\Util::writeLog('file sharing',
@@ -487,6 +501,21 @@ class Shared extends \OC\Files\Storage\Common {
}
/**
+ * @brief does the group share already has a user specific unique name
+ * @return bool
+ */
+ private function uniqueNameSet() {
+ return (isset($this->share['unique_name']) && $this->share['unique_name']);
+ }
+
+ /**
+ * @brief the share now uses a unique name of this user
+ */
+ private function setUniqueName() {
+ $this->share['unique_name'] = true;
+ }
+
+ /**
* @brief get share ID
* @return integer unique share ID
*/