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

Commit

Permalink
NodesList CLI table rendering error when no nodes.
Browse files Browse the repository at this point in the history
Disable CacheStreamLayer when in command line
Change empty_recycle to a dedicated action (no more selectAll + delete). Send in background.
  • Loading branch information
cdujeu committed Sep 3, 2016
1 parent ff6b8a4 commit 8484f21
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
40 changes: 40 additions & 0 deletions core/src/plugins/access.fs/FsAccessDriver.php
Expand Up @@ -919,6 +919,46 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface

break;

case "empty_recycle":

$taskId = $request->getAttribute("pydio-task-id");
if($taskId === null && !ConfService::currentContextIsCommandLine()){
$task = TaskService::actionAsTask($ctx, $action, $httpVars);
$response = TaskService::getInstance()->enqueueTask($task, $request, $response);
break;
}
// List recycle content
$fakeResp = new Response();
$recycleBin = RecycleBinManager::getRelativeRecycle();
$newRequest = $request->withAttribute("action", "ls");
$newRequest = $newRequest->withParsedBody(["dir" => $recycleBin]);
$this->switchAction($newRequest, $fakeResp);
$b = $fakeResp->getBody();
if($b instanceof SerializableResponseStream){
foreach($b->getChunks() as $chunk){
if($chunk instanceof NodesList){
$list = $chunk;
}
}
}
if(!isSet($list)){
throw new PydioException("Could not retrieve recycle bin content");
}
$selection = UserSelection::fromContext($ctx, []);
$selection->initFromNodes($list->getChildren());
$logMessages = [];
$errorMessage = $this->delete($selection, $logMessages, $taskId);
if (count($logMessages)) {
$logMessage = new UserMessage(join("\n", $logMessages));
}
if($errorMessage) {
throw new PydioException(TextEncoder::toUTF8($errorMessage));
}
$this->logInfo("Delete", ["files"=>$this->addSlugToPath($selection)]);
$nodesDiffs->remove($selection->getFiles());

break;

//------------------------------------
// COPY / MOVE
//------------------------------------
Expand Down
22 changes: 15 additions & 7 deletions core/src/plugins/access.fs/fsActions.xml
Expand Up @@ -195,18 +195,26 @@
</action>
<action name="empty_recycle">
<gui text="220" title="221" src="trashcan_empty.png" iconClass="icon-ban-circle" accessKey="empty_recycle_access_key" hasAccessKey="true">
<context selection="false" dir="true" recycle="only" actionBar="true"
<context selection="true" dir="true" recycle="only" actionBar="true"
contextMenu="true" infoPanel="false" actionBarGroup="change_main"/>
<selectionContext dir="false" file="false" recycle="true" unique="true"/>
</gui>
<rightsContext noUser="true" userLogged="" read="true" write="true" adminOnly=""/>
<processing>
<serverCallback methodName="switchAction" restParams="/"/>
<clientCallback prepareModal="false"><![CDATA[
ajaxplorer.getContextHolder().selectAll();
window.setTimeout(function(){
pydio.getController().fireAction('delete');
}, 200);
]]></clientCallback>
</processing>
modal.showDialogForm('EmptyRecycle', 'empty_recycle_form', null, function(){
PydioApi.getClient().request({get_action:'empty_recycle'});
hideLightBox(true);
return false;
});
]]></clientCallback>
<clientForm id="empty_recycle_form"><![CDATA[
<div id="empty_recycle_form" action="empty_recycle" box_width="200">
<span ajxp_message_id="177">AJXP_MESSAGE[177]</span>
</div>
]]></clientForm>
</processing>
</action>
<action name="download" fileDefault="false">
<gui text="88" title="88" src="download_manager.png" iconClass="mdi mdi-download" accessKey="download_access_key" hasAccessKey="true">
Expand Down
4 changes: 3 additions & 1 deletion core/src/plugins/core.access/src/Model/NodesList.php
Expand Up @@ -255,7 +255,7 @@ public function render($output)
$collAttr = $column["attributeName"];
$headers[$collAttr] = $colTitle;
}
}else{
}else if(count($this->children)){
/** @var AJXP_Node $firstNode */
$firstNode = $this->children[0];
$headers["text"] = "Label"; //$firstNode->getLabel();
Expand All @@ -268,6 +268,8 @@ public function render($output)
$headers[$attName] = ucfirst($attName);
}
}
}else{
$headers["h"] = "No results found";
}
$table->setHeaders(array_values($headers));

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.cache/CoreCacheLoader.php
Expand Up @@ -68,7 +68,7 @@ public function getImplementation($pluginsService = null)
$pluginInstance = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_INSTANCE_CONFIG"], "Pydio\\Cache\\Core\\AbstractCacheDriver", $pluginsService);
}
self::$cacheInstance = $pluginInstance;
if($pluginInstance !== null && $pluginInstance instanceof AbstractCacheDriver && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)){
if(!ConfService::currentContextIsCommandLine() && $pluginInstance !== null && $pluginInstance instanceof AbstractCacheDriver && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)){
MetaStreamWrapper::appendMetaWrapper("pydio.cache", "\\Pydio\\Cache\\Core\\CacheStreamLayer");
}
}
Expand Down

0 comments on commit 8484f21

Please sign in to comment.