aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-26 21:20:05 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-26 21:20:05 +0100
commit7bff0681feea57c1eb2f81015d574063b848b616 (patch)
treee9d82d0d621002c7f39c234726bec1ca0cac7955 /apps
parent232518ac548a1d8f99c51fe391eb6132c1154dba (diff)
parent1be7da4a57ed006bd246f25dbe053b58b89557c9 (diff)
downloadnextcloud-server-7bff0681feea57c1eb2f81015d574063b848b616.tar.gz
nextcloud-server-7bff0681feea57c1eb2f81015d574063b848b616.zip
Merge pull request #15001 from owncloud/kill-share-proxy
Replace share proxy with a hook
Diffstat (limited to 'apps')
-rwxr-xr-xapps/files_encryption/tests/share.php3
-rw-r--r--apps/files_sharing/appinfo/app.php2
-rw-r--r--apps/files_sharing/lib/helper.php1
-rw-r--r--apps/files_sharing/lib/hooks.php16
-rw-r--r--apps/files_sharing/lib/proxy.php65
-rw-r--r--apps/files_sharing/tests/unsharechildren.php (renamed from apps/files_sharing/tests/proxy.php)14
-rw-r--r--apps/files_sharing/tests/updater.php1
7 files changed, 23 insertions, 79 deletions
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index 06feb630f27..2a9f0359c91 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -62,9 +62,6 @@ class Share extends TestCase {
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
- // clear and register hooks
- \OC_FileProxy::register(new \OCA\Files\Share\Proxy());
-
// create users
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true);
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 85002ff982b..a222973fc34 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -51,8 +51,6 @@ OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
OCP\Util::addScript('files_sharing', 'share');
OCP\Util::addScript('files_sharing', 'external');
-OC_FileProxy::register(new OCA\Files\Share\Proxy());
-
\OC::$server->getActivityManager()->registerExtension(function() {
return new \OCA\Files_Sharing\Activity(
\OC::$server->query('L10NFactory'),
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index 712b9fa29dd..236be15a95a 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -36,6 +36,7 @@ class Helper {
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Shared_Updater', 'postDeleteHook');
\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');
diff --git a/apps/files_sharing/lib/hooks.php b/apps/files_sharing/lib/hooks.php
index dc7317c5c7d..c3588ecdfe5 100644
--- a/apps/files_sharing/lib/hooks.php
+++ b/apps/files_sharing/lib/hooks.php
@@ -22,6 +22,8 @@
namespace OCA\Files_Sharing;
+use OC\Files\Filesystem;
+
class Hooks {
public static function deleteUser($params) {
@@ -35,4 +37,18 @@ class Hooks {
$manager->removeUserShares($params['uid']);
}
+ public static function unshareChildren($params) {
+ $path = Filesystem::getView()->getAbsolutePath($params['path']);
+ $view = new \OC\Files\View('/');
+
+ // find share mount points within $path and unmount them
+ $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountedShares = $mountManager->findIn($path);
+ foreach ($mountedShares as $mount) {
+ if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
+ $mountPoint = $mount->getMountPoint();
+ $view->unlink($mountPoint);
+ }
+ }
+ }
}
diff --git a/apps/files_sharing/lib/proxy.php b/apps/files_sharing/lib/proxy.php
deleted file mode 100644
index 538d8bcfecf..00000000000
--- a/apps/files_sharing/lib/proxy.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * @author Björn Schießle <schiessle@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\Files\Share;
-use OCA\Files_Sharing\Helper;
-
-class Proxy extends \OC_FileProxy {
-
- /**
- * check if the deleted folder contains share mount points and unshare them
- *
- * @param string $path
- */
- public function preUnlink($path) {
- $this->unshareChildren($path);
- }
-
- /**
- * check if the deleted folder contains share mount points and unshare them
- *
- * @param string $path
- */
- public function preRmdir($path) {
- $this->unshareChildren($path);
- }
-
- /**
- * unshare shared items below the deleted folder
- *
- * @param string $path
- */
- private function unshareChildren($path) {
- $view = new \OC\Files\View('/');
-
- // find share mount points within $path and unmount them
- $mountManager = \OC\Files\Filesystem::getMountManager();
- $mountedShares = $mountManager->findIn($path);
- foreach ($mountedShares as $mount) {
- if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
- $mountPoint = $mount->getMountPoint();
- $view->unlink($mountPoint);
- }
- }
- }
-
-}
diff --git a/apps/files_sharing/tests/proxy.php b/apps/files_sharing/tests/unsharechildren.php
index cfdc7741733..b49180fdc83 100644
--- a/apps/files_sharing/tests/proxy.php
+++ b/apps/files_sharing/tests/unsharechildren.php
@@ -22,13 +22,13 @@
*
*/
+namespace OCA\Files_sharing\Tests;
use OCA\Files\Share;
-/**
- * Class Test_Files_Sharing_Proxy
- */
-class Test_Files_Sharing_Proxy extends OCA\Files_sharing\Tests\TestCase {
+class UnshareChildren extends TestCase {
+
+ protected $subsubfolder;
const TEST_FOLDER_NAME = '/folder_share_api_test';
@@ -37,9 +37,7 @@ class Test_Files_Sharing_Proxy extends OCA\Files_sharing\Tests\TestCase {
protected function setUp() {
parent::setUp();
- // load proxies
- OC::$CLASSPATH['OCA\Files\Share\Proxy'] = 'files_sharing/lib/proxy.php';
- OC_FileProxy::register(new OCA\Files\Share\Proxy());
+ \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
$this->folder = self::TEST_FOLDER_NAME;
$this->subfolder = '/subfolder_share_api_test';
@@ -66,7 +64,7 @@ class Test_Files_Sharing_Proxy extends OCA\Files_sharing\Tests\TestCase {
/**
* @medium
*/
- function testpreUnlink() {
+ function testUnshareChildren() {
$fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index f019fc6a4b2..df1bbe1cc66 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -66,7 +66,6 @@ class Test_Files_Sharing_Updater extends OCA\Files_sharing\Tests\TestCase {
\OC_App::enable('files_trashbin');
\OCA\Files_Trashbin\Trashbin::registerHooks();
- OC_FileProxy::register(new OCA\Files\Share\Proxy());
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
$this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);