From 420b5273b19394b79f7d87cc6c10271f38a3d9d7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 22 Apr 2016 19:44:07 +0200 Subject: [PATCH 1/3] There is no need to do old etag propagation Etags are calculated differently now and don't require manual updating. --- apps/files_sharing/lib/helper.php | 5 -- apps/files_sharing/lib/updater.php | 96 ------------------------------ 2 files changed, 101 deletions(-) diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index c09694e988..8dad84eca4 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -36,15 +36,10 @@ use OCP\User; class Helper { public static function registerHooks() { - \OCP\Util::connectHook('OC_Filesystem', 'delete', '\OC\Files\Cache\Shared_Updater', 'deleteHook'); \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook'); \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); \OCP\Util::connectHook('OC_Appconfig', 'post_set_value', '\OCA\Files\Share\Maintainer', 'configChangeHook'); - \OCP\Util::connectHook('OCP\Share', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'postShareHook'); - \OCP\Util::connectHook('OCP\Share', 'post_unshare', '\OC\Files\Cache\Shared_Updater', 'postUnshareHook'); - \OCP\Util::connectHook('OCP\Share', 'post_unshareFromSelf', '\OC\Files\Cache\Shared_Updater', 'postUnshareFromSelfHook'); - \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); } diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 0e6433b112..de68e2ea0f 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -29,30 +29,6 @@ namespace OC\Files\Cache; class Shared_Updater { - /** - * Walk up the users file tree and update the etags. - * - * @param string $user user id - * @param string $path share mount point path, relative to the user's "files" folder - */ - static private function correctUsersFolder($user, $path) { - // $path points to the mount point which is a virtual folder, so we start with - // the parent - $path = '/' . ltrim($path, '/'); - $path = '/files' . dirname($path); - \OC\Files\Filesystem::initMountPoints($user); - $view = new \OC\Files\View('/' . $user); - if ($view->file_exists($path)) { - while ($path !== dirname($path)) { - $etag = $view->getETag($path); - $view->putFileInfo($path, array('etag' => $etag)); - $path = dirname($path); - } - } else { - \OCP\Util::writeLog('files_sharing', 'can not update etags on ' . $path . ' for user ' . $user . '. Path does not exists', \OCP\Util::DEBUG); - } - } - /** * @param array $params */ @@ -108,78 +84,6 @@ class Shared_Updater { } } - /** - * @param array $params - */ - static public function deleteHook($params) { - $path = $params['path']; - } - - /** - * update etags if a file was shared - * @param array $params - */ - static public function postShareHook($params) { - - if ($params['itemType'] === 'folder' || $params['itemType'] === 'file') { - - $shareWith = $params['shareWith']; - $shareType = $params['shareType']; - - if ($shareType === \OCP\Share::SHARE_TYPE_USER) { - self::correctUsersFolder($shareWith, $params['fileTarget']); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { - foreach (\OC_Group::usersInGroup($shareWith) as $user) { - self::correctUsersFolder($user, $params['fileTarget']); - } - } - } - } - - /** - * update etags if a file was unshared - * - * @param array $params - */ - static public function postUnshareHook($params) { - - // only update etags for file/folders shared to local users/groups - if (($params['itemType'] === 'file' || $params['itemType'] === 'folder') && - $params['shareType'] !== \OCP\Share::SHARE_TYPE_LINK && - $params['shareType'] !== \OCP\Share::SHARE_TYPE_REMOTE) { - - $deletedShares = isset($params['deletedShares']) ? $params['deletedShares'] : array(); - - foreach ($deletedShares as $share) { - if ($share['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) { - foreach (\OC_Group::usersInGroup($share['shareWith']) as $user) { - self::correctUsersFolder($user, $share['fileTarget']); - } - } else { - self::correctUsersFolder($share['shareWith'], $share['fileTarget']); - } - } - } - } - - /** - * update etags if file was unshared from self - * @param array $params - */ - static public function postUnshareFromSelfHook($params) { - if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { - foreach ($params['unsharedItems'] as $item) { - if ($item['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) { - foreach (\OC_Group::usersInGroup($item['shareWith']) as $user) { - self::correctUsersFolder($user, $item['fileTarget']); - } - } else { - self::correctUsersFolder($item['shareWith'], $item['fileTarget']); - } - } - } - } - /** * clean up oc_share table from files which are no longer exists * From 27c9d8a6901de8142c4f597d5c94503aca80e50b Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 25 Apr 2016 08:50:05 +0200 Subject: [PATCH 2/3] Not logged in is original calculated target --- build/integration/features/sharing-v1.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 49c2dbf58c..d67afede95 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -209,7 +209,7 @@ Feature: sharing When sending "GET" to "/apps/files_sharing/api/v1/shares" Then the OCS status code should be "100" And the HTTP status code should be "200" - And File "textfile0 (2).txt" should be included in the response + And File "textfile0.txt" should be included in the response Scenario: getting all shares of a user using another user Given user "user0" exists @@ -280,7 +280,7 @@ Feature: sharing | share_type | 0 | | share_with | user1 | | file_source | A_NUMBER | - | file_target | /textfile0 (2).txt | + | file_target | /textfile0.txt | | path | /textfile0.txt | | permissions | 19 | | stime | A_NUMBER | From 00122c166a386b52a127e97cfaee78cd8fd44e58 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 25 Apr 2016 09:33:17 +0200 Subject: [PATCH 3/3] Properly get the internal path for a cachejail move --- lib/private/Files/Cache/Wrapper/CacheJail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 3148d1412f..d737d28fc8 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -303,6 +303,6 @@ class CacheJail extends CacheWrapper { if ($sourceCache === $this) { return $this->move($sourcePath, $targetPath); } - return $this->cache->moveFromCache($sourceCache, $sourcePath, $targetPath); + return $this->cache->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); } }