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

Commit

Permalink
Do not disable task / mq for minisites, as more actions rely on it.
Browse files Browse the repository at this point in the history
Fix powerFS
  • Loading branch information
cdujeu committed Oct 6, 2016
1 parent 2cb8a77 commit cdacb3d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 18 deletions.
21 changes: 13 additions & 8 deletions core/src/plugins/action.powerfs/PowerFSController.php
Expand Up @@ -22,6 +22,8 @@
namespace Pydio\Action\Compression;

use Exception;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\NodesDiff;
use Pydio\Access\Core\Model\UserSelection;
use Pydio\Access\Driver\StreamProvider\FS\FsAccessWrapper;

Expand Down Expand Up @@ -96,7 +98,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$response = $response->withBody($fileReader);
} else {
$response = $response->withHeader("Content-type", "text/html");
$response->getBody()->write("<script>alert('Cannot find archive! Is ZIP correctly installed?');</script>");
$response->getBody()->write("<script>alert('".str_replace("'", "\'", $mess["powerfs.5"])."');</script>");
}
break;

Expand All @@ -109,7 +111,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
if ($taskId === null) {
$task = TaskService::actionAsTask($ctx, $request->getAttribute("action"), $httpVars);
$task->setLabel($mess['powerfs.1']);
$task->setFlags(Task::FLAG_STOPPABLE | Task::FLAG_HAS_PROGRESS);
$task->setFlags(Task::FLAG_HAS_PROGRESS);
TaskService::getInstance()->enqueueTask($task, $request, $response);
return;
}
Expand Down Expand Up @@ -177,25 +179,28 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
}
$tok = strtok("\n");
}
if ($finishedEchoed) $percent = 100;
else $percent = min(round(count($handled) / count($todo) * 100), 100);
TaskService::getInstance()->updateTaskStatus($taskId, Task::STATUS_RUNNING, "Creating archive " . $percent . " %", null, $percent);
if ($finishedEchoed) $newPercent = 100;
else $newPercent = min(round(count($handled) / count($todo) * 100), 100);
if($newPercent !== $percent){
TaskService::getInstance()->updateTaskStatus($taskId, Task::STATUS_RUNNING, str_replace("%s", $percent, $mess["powerfs.4"]), null, $percent);
}
$percent = $newPercent;
}
// avoid a busy wait
if ($percent < 100) usleep(1);
}
pclose($proc);
TaskService::getInstance()->updateTaskStatus($taskId, Task::STATUS_COMPLETE, "");
if ($request->getAttribute("action") === "compress") {
$newNode = new \Pydio\Access\Core\Model\AJXP_Node($urlBase . $dir . "/" . $archiveName);
$nodesDiff = new \Pydio\Access\Core\Model\NodesDiff();
$newNode = new AJXP_Node($urlBase . $dir . "/" . $archiveName);
$nodesDiff = new NodesDiff();
$nodesDiff->add($newNode);
Controller::applyHook("msg.instant", array($ctx, $nodesDiff->toXML()));
} else {
$archiveName = str_replace("'", "\'", $originalArchiveParam);
$jsCode = " PydioApi.getClient().downloadSelection(null, $('download_form'), 'postcompress_download', {ope_id:'" . $opeId . "',archive_name:'" . $archiveName . "'}); ";
$actionTrigger = new JsActionTrigger($jsCode, 0);
Controller::applyHook("msg.instant", array($ctx, $actionTrigger->toXML()));
Controller::applyHook("msg.instant", array($ctx, $actionTrigger->toXML(), $ctx->getUser()->getId()));

}

Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/action.powerfs/i18n/cs.php
Expand Up @@ -23,4 +23,6 @@
"1" => "Vytváří se archiv, chvíli strpení",
"2" => "Znovu načíst aktuální adresář",
"3" => "Stahování archivu by mělo začít automaticky",
"4" => "Vytváří se archiv - %s%",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 3 additions & 1 deletion core/src/plugins/action.powerfs/i18n/de.php
Expand Up @@ -22,5 +22,7 @@
// will be replaced by the application title
"1" => "Archiv wird erstellt. Bitte warten...",
"2" => "Aktuellen Ordner neu laden",
"3" => "Der Download des Archivs sollte automatisch starten"
"3" => "Der Download des Archivs sollte automatisch starten",
"4" => "Archiv wird erstellt - %s%",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 3 additions & 1 deletion core/src/plugins/action.powerfs/i18n/en.php
Expand Up @@ -20,7 +20,9 @@
*/
$mess = array(
// will be replaced by the application title
"1" => "Creating archive, please wait",
"1" => "Launching archive creation in background, please wait.",
"2" => "Reload current folder",
"3" => "Archive download should start automatically",
"4" => "Creating archive - %s% done",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 3 additions & 1 deletion core/src/plugins/action.powerfs/i18n/fr.php
Expand Up @@ -22,5 +22,7 @@
// will be replaced by the application title
"1" => "Création de l'archive, veuillez patienter",
"2" => "Rechargement du répertoire",
"3" => "Le téléchargement de l'archive devrait démarrer automatiquement"
"3" => "Le téléchargement de l'archive devrait démarrer automatiquement",
"4" => "Création de l'archive - %s%",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 3 additions & 1 deletion core/src/plugins/action.powerfs/i18n/it.php
Expand Up @@ -22,5 +22,7 @@
// will be replaced by the application title
"1" => "Creazione archivio. Attendere...",
"2" => "Ricaricamento cartella corrente",
"3" => "Il download dell'archivio partità automaticamente"
"3" => "Il download dell'archivio partità automaticamente",
"4" => "Creazione archivio - %s%",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 3 additions & 1 deletion core/src/plugins/action.powerfs/i18n/pt.php
Expand Up @@ -22,5 +22,7 @@
// will be replaced by the application title
"1" => "A criar o ficheiro, por favor aguarde",
"2" => "Actualize a pasta actual",
"3" => "A Transferência do ficheiro deverá começar automaticamente"
"3" => "A Transferência do ficheiro deverá começar automaticamente",
"4" => "A criar o ficheiro - %s%",
"5" => "Cannot find corresponding archive for download! Did you make sure to install the Zip binary on your server?",
);
4 changes: 2 additions & 2 deletions core/src/plugins/core.mq/class.PydioInstantMessenger.js
Expand Up @@ -33,7 +33,7 @@ Class.create("PydioInstantMessenger", {
initialize : function(){
"use strict";

if(window.ajxpMinisite) return;
//if(window.ajxpMinisite) return;

this.clientId = window.ajxpBootstrap.parameters.get("SECURE_TOKEN");
this.configs = pydio.getPluginConfigs("mq");
Expand Down Expand Up @@ -63,7 +63,7 @@ Class.create("PydioInstantMessenger", {

initForRepoId:function(repoId){

if(window.WebSocket && this.configs.get("WS_ACTIVE")){
if(window.WebSocket && !window.ajxpMinisite && this.configs.get("WS_ACTIVE")){

if(this.ws) {
if(!repoId){
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.mq/manifest.xml
Expand Up @@ -73,7 +73,7 @@
<rightsContext adminOnly="false" noUser="true" read="false" userLogged="true" write="false"/>
<processing>
<clientListener name="init"><![CDATA[
if(!pydio.mqObserver && !pydio.mqObserverLoading && !window.ajxpMinisite){
if(!pydio.mqObserver && !pydio.mqObserverLoading){
pydio.mqObserverLoading = true;
ResourcesManager.prototype.loadJSResource('plugins/core.mq/class.PydioInstantMessenger.js', 'PydioInstantMessenger', function(){
pydio.mqObserver = new PydioInstantMessenger();
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/core.tasks/src/TaskService.php
Expand Up @@ -90,9 +90,9 @@ public function enqueueTask(Task $task, ServerRequestInterface $request = null,
return $response;
}

$minisite = $request !== null && $request->getAttribute("minisite");
//$minisite = $request !== null && $request->getAttribute("minisite");

if(ConfService::backgroundActionsSupported() && !ApplicationState::sapiIsCli() && !$minisite) {
if(ConfService::backgroundActionsSupported() && !ApplicationState::sapiIsCli() /*&& !$minisite*/) {

CliRunner::applyTaskInBackground($task);
return $response;
Expand Down

1 comment on commit cdacb3d

@Nanomani
Copy link
Contributor

@Nanomani Nanomani commented on cdacb3d Oct 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works better for minisite.
But this PR created after this is needed for winOS :-)
#1229

Please sign in to comment.