Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fixing the ocs remote sharing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ghecquet committed Jun 28, 2016
1 parent c67a76e commit d59c901
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 92 deletions.
13 changes: 13 additions & 0 deletions core/src/plugins/access.webdav/src/Driver.php
Expand Up @@ -95,6 +95,19 @@ public static function convertPath($node) {
$basePath = ltrim($repository->getContextOption($ctx, "PATH"), "/");
$path = $node->getPath();

$contentFilters = $node->getRepository()->getContentFilter();

if (isset($contentFilters)) {
$contentFilters = $contentFilters->filters;

foreach ($contentFilters as $key => $value) {
if ($value == $path || empty($path)) {
$path = $key;
break;
}
}
}

if (isset($path)) {
return "/" . $basePath . $path;
}
Expand Down
Expand Up @@ -95,6 +95,7 @@ public function onComplete(CompleteEvent $event)
$body = $response->getBody();

$contents = $body->getContents();

$contents = preg_replace("/xmlns(:[A-Za-z0-9_]*)?=(\"|\')DAV:(\\2)/","xmlns\\1=\\2urn:DAV\\2",$contents);
$contents = preg_replace("/\n/","",$contents);

Expand Down
6 changes: 6 additions & 0 deletions core/src/plugins/core.access/src/CoreAccessHandler.php
Expand Up @@ -40,6 +40,12 @@
*/
class CoreAccessHandler extends Plugin
{
public function init(ContextInterface $ctx, $options = [])
{
parent::init($ctx, $options); // TODO: Change the autogenerated stub
MetaStreamWrapper::register();
}

/**
* @param ServerRequestInterface $requestInterface
* @param ResponseInterface $responseInterface
Expand Down
13 changes: 11 additions & 2 deletions core/src/plugins/core.access/src/Stream/MetadataCachingStream.php
Expand Up @@ -25,6 +25,9 @@ class MetadataCachingStream implements StreamInterface
/** @var string uri */
private $uri;

/** @var array contentFilters */
private $contentFilters;

/** @var string path */
private $path;

Expand All @@ -41,6 +44,7 @@ public function __construct(
StreamInterface $target = null
) {
$this->uri = $node->getUrl();
$this->contentFilters = $node->getRepository()->getContentFilter()->filters;
$this->path = parse_url($this->uri, PHP_URL_PATH);

$this->stream = $stream;
Expand Down Expand Up @@ -96,8 +100,13 @@ public function stat() {
// So storing them in a local cache
if (is_array($stats[0])) {
foreach ($stats as $stat) {
$path = $stat["name"];
$key = rtrim($this->uri . "/" . $path, "/");
$path = "/" . $stat["name"];

if (isset($this->contentFilters[$path])) {
$path = $this->contentFilters[$path];
}

$key = rtrim($this->uri . $path, "/");
self::$stat[$key] = $stat;
}
} else {
Expand Down
17 changes: 8 additions & 9 deletions core/src/plugins/core.cache/CacheStreamLayer.php
Expand Up @@ -21,6 +21,7 @@
namespace Pydio\Cache\Core;


use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\SchemeTranslatorWrapper;
use Pydio\Core\Services\CacheService;

Expand All @@ -30,12 +31,10 @@
class CacheStreamLayer extends SchemeTranslatorWrapper
{
public static function clearStatCache($path){
$scheme = parse_url($path, PHP_URL_SCHEME);
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, str_replace($scheme . "://", "stat://", $path));
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, self::computeCacheId($path, "stat"));
}
public static function clearDirCache($path){
$scheme = parse_url($path, PHP_URL_SCHEME);
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, str_replace($scheme . "://", "list://", $path));
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, self::computeCacheId($path, "list"));
}

private $currentListingOrig = null;
Expand All @@ -49,16 +48,16 @@ public static function clearDirCache($path){
* @param $type
* @return string
*/
protected function computeCacheId($path, $type){
protected static function computeCacheId($path, $type){

return AbstractCacheDriver::computeIdForNode(new AJXP_Node($path), $type);

return AbstractCacheDriver::computeIdForNode(new \Pydio\Access\Core\Model\AJXP_Node($path), $type);

}

// Keep listing in cache
public function dir_opendir($path, $options)
{
$id = $this->computeCacheId($path, "list");
$id = self::computeCacheId($path, "list");
if(CacheService::contains(AJXP_CACHE_SERVICE_NS_NODES, $id)){
$this->currentListingRead = $this->currentListingOrig = CacheService::fetch(AJXP_CACHE_SERVICE_NS_NODES, $id);
return true;
Expand Down Expand Up @@ -107,7 +106,7 @@ public function dir_rewinddir()

public function url_stat($path, $flags)
{
$id = $this->computeCacheId($path, "stat");
$id = self::computeCacheId($path, "stat");
if(CacheService::contains(AJXP_CACHE_SERVICE_NS_NODES, $id)){
$stat = CacheService::fetch(AJXP_CACHE_SERVICE_NS_NODES, $id);
if(is_array($stat)) return $stat;
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.cache/CoreCacheLoader.php
Expand Up @@ -69,7 +69,7 @@ public function getImplementation($pluginsService = null)
}
self::$cacheInstance = $pluginInstance;
if($pluginInstance !== null && $pluginInstance instanceof AbstractCacheDriver && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)){
MetaStreamWrapper::appendMetaWrapper("pydio.cache", "\\Pydio\\Cache\\Core\\CacheStreamLayer");
//MetaStreamWrapper::appendMetaWrapper("pydio.cache", "\\Pydio\\Cache\\Core\\CacheStreamLayer");
}
}

Expand Down

0 comments on commit d59c901

Please sign in to comment.