diff options
Diffstat (limited to 'apps/files_external/lib/config.php')
-rwxr-xr-x | apps/files_external/lib/config.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 952463b8015..92bb891ca21 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -118,6 +118,22 @@ class OC_Mount_Config { } $manager->addMount($mount); } + + if ($data['user']) { + $user = \OC::$server->getUserManager()->get($data['user']); + $userView = new \OC\Files\View('/' . $user->getUID() . '/files'); + $changePropagator = new \OC\Files\Cache\ChangePropagator($userView); + $etagPropagator = new \OCA\Files_External\EtagPropagator($user, $changePropagator, \OC::$server->getConfig()); + $etagPropagator->propagateDirtyMountPoints(); + \OCP\Util::connectHook( + \OC\Files\Filesystem::CLASSNAME, + \OC\Files\Filesystem::signal_create_mount, + $etagPropagator, 'updateHook'); + \OCP\Util::connectHook( + \OC\Files\Filesystem::CLASSNAME, + \OC\Files\Filesystem::signal_delete_mount, + $etagPropagator, 'updateHook'); + } } /** @@ -463,6 +479,7 @@ class OC_Mount_Config { $priority = null) { $backends = self::getBackends(); $mountPoint = OC\Files\Filesystem::normalizePath($mountPoint); + $relMountPoint = $mountPoint; if ($mountPoint === '' || $mountPoint === '/') { // can't mount at root folder return false; @@ -495,6 +512,10 @@ class OC_Mount_Config { } $mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL); + // who else loves multi-dimensional array ? + $isNew = !isset($mountPoints[$mountType]) || + !isset($mountPoints[$mountType][$applicable]) || + !isset($mountPoints[$mountType][$applicable][$mountPoint]); $mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType); // Set default priority if none set @@ -510,7 +531,19 @@ class OC_Mount_Config { self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints); - return self::getBackendStatus($class, $classOptions, $isPersonal); + $result = self::getBackendStatus($class, $classOptions, $isPersonal); + if ($result && $isNew) { + \OC_Hook::emit( + \OC\Files\Filesystem::CLASSNAME, + \OC\Files\Filesystem::signal_create_mount, + array( + \OC\Files\Filesystem::signal_param_path => $relMountPoint, + \OC\Files\Filesystem::signal_param_mount_type => $mountType, + \OC\Files\Filesystem::signal_param_users => $applicable, + ) + ); + } + return $result; } /** @@ -523,6 +556,7 @@ class OC_Mount_Config { */ public static function removeMountPoint($mountPoint, $mountType, $applicable, $isPersonal = false) { // Verify that the mount point applies for the current user + $relMountPoints = $mountPoint; if ($isPersonal) { if ($applicable != OCP\User::getUser()) { return false; @@ -543,6 +577,15 @@ class OC_Mount_Config { } } self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints); + \OC_Hook::emit( + \OC\Files\Filesystem::CLASSNAME, + \OC\Files\Filesystem::signal_delete_mount, + array( + \OC\Files\Filesystem::signal_param_path => $relMountPoints, + \OC\Files\Filesystem::signal_param_mount_type => $mountType, + \OC\Files\Filesystem::signal_param_users => $applicable, + ) + ); return true; } |