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

Commit

Permalink
Fix cleanExpiredLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Sep 12, 2016
1 parent cfd28f2 commit 78b4900
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
5 changes: 3 additions & 2 deletions core/src/plugins/action.share/res/react/model/ShareModel.js
Expand Up @@ -870,8 +870,9 @@
}

static buildDirectDownloadUrl(node, publicLink, contentProvider = false){
let ctString = contentProvider ? '&ct=true' : '';
return publicLink + (publicLink.indexOf('?') !== -1 ? '&' : '?') + 'dl=true'+ ctString +'&file=/'+encodeURIComponent(node.getLabel());
let ctString = contentProvider ? '?ct=true' : '';
let link = publicLink.split('--').shift();
return link + (link.endsWith('/')? '' : '/') + 'dl/'+encodeURIComponent(node.getLabel()) + ctString;
}

static qrcodeEnabled(){
Expand Down
10 changes: 10 additions & 0 deletions core/src/plugins/action.share/src/Store/ShareMetaManager.php
Expand Up @@ -24,6 +24,7 @@

use Pydio\Core\Services\RepositoryService;
use Pydio\Share\Model\CompositeShare;
use Pydio\Share\Model\ShareLink;

defined('AJXP_EXEC') or die('Access not allowed');
define('AJXP_SHARED_META_NAMESPACE', 'ajxp_shared');
Expand Down Expand Up @@ -175,6 +176,15 @@ protected function compositeShareFromMetaWithScope($node, $scope = "private"){
foreach($repoData["links"] as $link){
$composite->addLink($link);
}
if($composite->isInvalid()){
// Clear meta and skip
$this->removeShareFromMeta($node, $repoId);
/** @var ShareLink[] $link */
foreach ($repoData['links'] as $link){
$this->removeShareFromMeta($node, $link->getHash());
}
continue;
}
$composites[] = $composite;
}
return $composites;
Expand Down
30 changes: 15 additions & 15 deletions core/src/plugins/action.share/src/Store/ShareStore.php
Expand Up @@ -737,12 +737,11 @@ public function clearExpiredFiles($currentUser = true)
*/
private function deleteExpiredPubliclet($elementId, $data){

// TODO: REWRITE THIS FUNCTION

if($this->context->hasUser() || $this->context->getUser()->getId() != $data["OWNER_ID"]){

/**
if(!$this->context->hasUser() || $this->context->getUser()->getId() !== $data["OWNER_ID"]){
AuthService::logUser($data["OWNER_ID"], "", true);
}
**/
$repoObject = $data["REPOSITORY"];
if(!($repoObject instanceof Repository)) {
$repoObject = RepositoryService::getRepositoryById($data["REPOSITORY"]);
Expand All @@ -758,19 +757,20 @@ private function deleteExpiredPubliclet($elementId, $data){
// Cannot load this repository anymore.
}
}
if($repoLoaded && isSet($data["FILE_PATH"])){
// @TODO : ADD USER IN URL
$ajxpNode = new AJXP_Node("pydio://".$repoObject->getId().$data["FILE_PATH"]);
}
$this->deleteShare($data['SHARE_TYPE'], $elementId, false, true);
if(isSet($ajxpNode)){
try{
$this->getMetaManager()->removeShareFromMeta($ajxpNode, $elementId);
}catch (\Exception $e){

$ajxpNode = null;
if($repoLoaded && $repoObject->hasParent()){
if(isSet($data["FILE_PATH"])){
$filePath = $data["FILE_PATH"];
$ajxpNode = new AJXP_Node("pydio://".$data["OWNER_ID"]."@".$repoObject->getParentId().$filePath);
}else if($repoObject->hasContentFilter()){
$filePath = $data["FILE_PATH"] = $repoObject->getContentFilter()->getUniquePath();
$ajxpNode = new AJXP_Node("pydio://".$data["OWNER_ID"]."@".$repoObject->getParentId().'/'.$filePath);
}
gc_collect_cycles();
}
Logger::debug("sharestore", "Delete share now !");
$this->deleteShare($data['SHARE_TYPE'], $elementId, false, true, $ajxpNode);

gc_collect_cycles();

}

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.tasks/src/TaskController.php
Expand Up @@ -79,7 +79,7 @@ protected function initTaskFromApi(ServerRequestInterface $request, Task &$task)
}
if(count($task->nodes)){
foreach($task->nodes as $index => $path){
$task->nodes[$index] = "pydio://".$task->getWsId().$path;
$task->nodes[$index] = "pydio://".$task->getUserId()."@".$task->getWsId().$path;
}
}
}
Expand Down

0 comments on commit 78b4900

Please sign in to comment.