diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 990d99705884..90bb17c75879 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -25,6 +25,8 @@ use OC\Files\Filesystem; use OCA\Files_Sharing\ISharedStorage; use OCA\Files_Sharing\SharedMount; +use OC\Files\ObjectStore\EosUtil; + /** * Convert target path to source path and pass the function call to the correct storage provider @@ -396,11 +398,69 @@ public function touch($path, $mtime = null) { return false; } + + public static function setup($options) { /* HUGO in an normal request this hook is called at least twice, reducing performance, so we cached*/ if(isset($GLOBALS["shared_setup_hook"])) { return; } + + + #KUBA: avoid mounting all shared storages if not necessary: + #\OCP\Util::writeLog('KUBA',"PATH" . __FUNCTION__ . "($kuba_path) dir=".$_GET["dir"]." REQ_URI=".$_SERVER['REQUEST_URI'], \OCP\Util::ERROR); + + $mount_shared_stuff = false; + + if($_GET["view"] == "sharingin" or $_GET["view"] == "sharingout" or $_GET["view"] == "sharinglinks") + { + $mount_shared_stuff = true; + } + else + { + $uri_path=""; + + if ($_SERVER['REQUEST_METHOD'] === 'POST') + { + if(isset($_POST["dir"])) + { + $uri_path=$_POST["dir"]; + } + else + { + $mount_shared_stuff = true; # if dir is not defined, take the safe bet + } + } + else + { + if(isset($_GET["dir"])) + { + $uri_path=$_GET["dir"]; + } + else + { + $mount_shared_stuff = true; # if dir is not defined, take the safe bet + } + } + + if($uri_path) { + + if(EosUtil::isProjectURIPath($uri_path)) { $mount_shared_stuff = true; } + elseif (EosUtil::isSharedURIPath($uri_path)) { $mount_shared_stuff = true; } + + #\OCP\Util::writeLog('KUBA',"EosUtil::isSharedURIPath" . __FUNCTION__ . "uri_path=|${uri_path}| ->".EosUtil::isSharedURIPath($uri_path), \OCP\Util::ERROR); + } + } + + if(!$mount_shared_stuff) + { + #\OCP\Util::writeLog('KUBA',"PATH" . __FUNCTION__ . "($kuba_path) dir=".$_GET["dir"]." NOT MOUNTING=".$mount_shared_stuff, \OCP\Util::ERROR); + return; + } + + #\OCP\Util::writeLog('KUBA',"PATH" . __FUNCTION__ . "($kuba_path) dir=".$_GET["dir"]." MOUNTING=".$mount_shared_stuff, \OCP\Util::ERROR); + + $shares = \OCP\Share::getItemsSharedWithUser('file', $options['user']); $manager = Filesystem::getMountManager(); $loader = Filesystem::getLoader();