aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/updater.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-07-02 15:35:15 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-07-02 15:39:38 +0200
commitea31ab7b5c0f50075d15e69b6f2f1940fe2ac00f (patch)
tree0ecab420a1bcce1699a2a443e028a657251701ca /apps/files_sharing/lib/updater.php
parent59629e688c3cc470279576524eac93041c253147 (diff)
downloadnextcloud-server-ea31ab7b5c0f50075d15e69b6f2f1940fe2ac00f.tar.gz
nextcloud-server-ea31ab7b5c0f50075d15e69b6f2f1940fe2ac00f.zip
rename mount point of children if parent was renamed
Diffstat (limited to 'apps/files_sharing/lib/updater.php')
-rw-r--r--apps/files_sharing/lib/updater.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php
index e114c3ba0ac..aac4ed196de 100644
--- a/apps/files_sharing/lib/updater.php
+++ b/apps/files_sharing/lib/updater.php
@@ -109,6 +109,7 @@ class Shared_Updater {
static public function renameHook($params) {
self::correctFolders($params['newpath']);
self::correctFolders(pathinfo($params['oldpath'], PATHINFO_DIRNAME));
+ self::renameChildren($params['oldpath'], $params['newpath']);
}
/**
@@ -209,4 +210,26 @@ class Shared_Updater {
$findAndRemoveShares->execute(array());
}
+ /**
+ * rename mount point from the children if the parent was renamed
+ *
+ * @param string $oldPath old path relative to data/user/files
+ * @param string $newPath new path relative to data/user/files
+ */
+ static private function renameChildren($oldPath, $newPath) {
+
+ $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
+ $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
+
+ $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
+ foreach ($mountedShares as $mount) {
+ if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
+ $mountPoint = $mount->getMountPoint();
+ $target = str_replace($absOldPath, $absNewPath, $mountPoint);
+ $mount->moveMount($target);
+ }
+ }
+ }
+
}