Skip to content

Commit

Permalink
optimization: do not mount shared spaces if dir parameter present in …
Browse files Browse the repository at this point in the history
…GET or POST requests
  • Loading branch information
moscicki committed Sep 18, 2015
1 parent d3f348e commit d82b87e
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions apps/files_sharing/lib/sharedstorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d82b87e

Please sign in to comment.