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

Commit 78b4900

Browse files
committed
Fix cleanExpiredLinks
1 parent cfd28f2 commit 78b4900

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

core/src/plugins/action.share/res/react/model/ShareModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,9 @@
870870
}
871871

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

877878
static qrcodeEnabled(){

core/src/plugins/action.share/src/Store/ShareMetaManager.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
use Pydio\Core\Services\RepositoryService;
2626
use Pydio\Share\Model\CompositeShare;
27+
use Pydio\Share\Model\ShareLink;
2728

2829
defined('AJXP_EXEC') or die('Access not allowed');
2930
define('AJXP_SHARED_META_NAMESPACE', 'ajxp_shared');
@@ -175,6 +176,15 @@ protected function compositeShareFromMetaWithScope($node, $scope = "private"){
175176
foreach($repoData["links"] as $link){
176177
$composite->addLink($link);
177178
}
179+
if($composite->isInvalid()){
180+
// Clear meta and skip
181+
$this->removeShareFromMeta($node, $repoId);
182+
/** @var ShareLink[] $link */
183+
foreach ($repoData['links'] as $link){
184+
$this->removeShareFromMeta($node, $link->getHash());
185+
}
186+
continue;
187+
}
178188
$composites[] = $composite;
179189
}
180190
return $composites;

core/src/plugins/action.share/src/Store/ShareStore.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,11 @@ public function clearExpiredFiles($currentUser = true)
737737
*/
738738
private function deleteExpiredPubliclet($elementId, $data){
739739

740-
// TODO: REWRITE THIS FUNCTION
741-
742-
if($this->context->hasUser() || $this->context->getUser()->getId() != $data["OWNER_ID"]){
743-
740+
/**
741+
if(!$this->context->hasUser() || $this->context->getUser()->getId() !== $data["OWNER_ID"]){
744742
AuthService::logUser($data["OWNER_ID"], "", true);
745743
}
744+
**/
746745
$repoObject = $data["REPOSITORY"];
747746
if(!($repoObject instanceof Repository)) {
748747
$repoObject = RepositoryService::getRepositoryById($data["REPOSITORY"]);
@@ -758,19 +757,20 @@ private function deleteExpiredPubliclet($elementId, $data){
758757
// Cannot load this repository anymore.
759758
}
760759
}
761-
if($repoLoaded && isSet($data["FILE_PATH"])){
762-
// @TODO : ADD USER IN URL
763-
$ajxpNode = new AJXP_Node("pydio://".$repoObject->getId().$data["FILE_PATH"]);
764-
}
765-
$this->deleteShare($data['SHARE_TYPE'], $elementId, false, true);
766-
if(isSet($ajxpNode)){
767-
try{
768-
$this->getMetaManager()->removeShareFromMeta($ajxpNode, $elementId);
769-
}catch (\Exception $e){
770-
760+
$ajxpNode = null;
761+
if($repoLoaded && $repoObject->hasParent()){
762+
if(isSet($data["FILE_PATH"])){
763+
$filePath = $data["FILE_PATH"];
764+
$ajxpNode = new AJXP_Node("pydio://".$data["OWNER_ID"]."@".$repoObject->getParentId().$filePath);
765+
}else if($repoObject->hasContentFilter()){
766+
$filePath = $data["FILE_PATH"] = $repoObject->getContentFilter()->getUniquePath();
767+
$ajxpNode = new AJXP_Node("pydio://".$data["OWNER_ID"]."@".$repoObject->getParentId().'/'.$filePath);
771768
}
772-
gc_collect_cycles();
773769
}
770+
Logger::debug("sharestore", "Delete share now !");
771+
$this->deleteShare($data['SHARE_TYPE'], $elementId, false, true, $ajxpNode);
772+
773+
gc_collect_cycles();
774774

775775
}
776776

core/src/plugins/core.tasks/src/TaskController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function initTaskFromApi(ServerRequestInterface $request, Task &$task)
7979
}
8080
if(count($task->nodes)){
8181
foreach($task->nodes as $index => $path){
82-
$task->nodes[$index] = "pydio://".$task->getWsId().$path;
82+
$task->nodes[$index] = "pydio://".$task->getUserId()."@".$task->getWsId().$path;
8383
}
8484
}
8585
}

0 commit comments

Comments
 (0)