From 526ea3fcba56502b9a3a5204221a0aa7e4fa538a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 17 Apr 2015 13:31:22 +0200 Subject: [PATCH] add rename hook for propagation --- .../lib/propagation/changewatcher.php | 15 +++++++++++++++ .../lib/propagation/propagationmanager.php | 1 + 2 files changed, 16 insertions(+) diff --git a/apps/files_sharing/lib/propagation/changewatcher.php b/apps/files_sharing/lib/propagation/changewatcher.php index fa5208b498..e5ca62c6d8 100644 --- a/apps/files_sharing/lib/propagation/changewatcher.php +++ b/apps/files_sharing/lib/propagation/changewatcher.php @@ -37,6 +37,21 @@ class ChangeWatcher { } } + public function renameHook($params) { + $path1 = $params['oldpath']; + $path2 = $params['newpath']; + $fullPath1 = $this->baseView->getAbsolutePath($path1); + $fullPath2 = $this->baseView->getAbsolutePath($path2); + $mount1 = $this->baseView->getMount($path1); + $mount2 = $this->baseView->getMount($path2); + if ($mount1 instanceof SharedMount) { + $this->propagateForOwner($mount1->getShare(), $mount1->getInternalPath($fullPath1), $mount1->getOwnerPropagator()); + } + if ($mount1 !== $mount2 and $mount2 instanceof SharedMount) { + $this->propagateForOwner($mount2->getShare(), $mount2->getInternalPath($fullPath2), $mount2->getOwnerPropagator()); + } + } + /** * @param array $share * @param string $internalPath diff --git a/apps/files_sharing/lib/propagation/propagationmanager.php b/apps/files_sharing/lib/propagation/propagationmanager.php index bf530d369b..14763a4df7 100644 --- a/apps/files_sharing/lib/propagation/propagationmanager.php +++ b/apps/files_sharing/lib/propagation/propagationmanager.php @@ -109,5 +109,6 @@ class PropagationManager { $this->listenToOwnerChanges($user->getUID(), $user->getUID()); \OC_Hook::connect('OC_Filesystem', 'write', $watcher, 'writeHook'); \OC_Hook::connect('OC_Filesystem', 'delete', $watcher, 'writeHook'); + \OC_Hook::connect('OC_Filesystem', 'rename', $watcher, 'renameHook'); } }