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

Commit c72f8b9

Browse files
committed
Merge branch 'jscore-deprototype' of https://github.com/pydio/pydio-core into jscore-deprototype
2 parents 3b6797d + 40fc8bd commit c72f8b9

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

core/src/plugins/action.compression/class.PluginCompression.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class PluginCompression extends AJXP_Plugin
3636
*/
3737
public function receiveAction($action, $httpVars, $fileVars)
3838
{
39-
//TODO : DESTROY THE PROGRESS FILE AT THE END OF THE PROCESS + POSSIBILITY TO CANCEL COMPRESS TO HAVE JUST THE TAR FILE
40-
//VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE MUST HAVE VAR !!
39+
//VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !!
4140
$messages = ConfService::getMessages();
4241
$repository = ConfService::getRepository();
4342
$userSelection = new UserSelection($repository, $httpVars);
@@ -62,7 +61,7 @@ public function receiveAction($action, $httpVars, $fileVars)
6261
if ($action == "compression") {
6362
$archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archiveName"]), AJXP_SANITIZE_FILENAME);
6463
$archiveFormat = $httpVars["type_archive"];
65-
$tabTypeArchive = [".tar", ".tar.gz", ".tar.bz2"];
64+
$tabTypeArchive = array(".tar", ".tar.gz", ".tar.bz2");
6665
$acceptedExtension = false;
6766
foreach ($tabTypeArchive as $extensionArchive) {
6867
if ($extensionArchive == $archiveFormat) {
@@ -74,8 +73,8 @@ public function receiveAction($action, $httpVars, $fileVars)
7473
throw new AJXP_Exception($messages["compression.16"]);
7574
}
7675
$typeArchive = $httpVars["type_archive"];
77-
//if we can run in background we do it
78-
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
76+
//if we can run in background we do it ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()
77+
if (1 == 2) {
7978
$archivePath = $currentDirPath.$archiveName;
8079
file_put_contents($progressCompressionFileName, $messages["compression.5"]);
8180
AJXP_Controller::applyActionInBackground($repository->getId(), "compression", $httpVars);
@@ -84,15 +83,15 @@ public function receiveAction($action, $httpVars, $fileVars)
8483
"repository_id" => $repository->getId(),
8584
"compression_id" => $compressionId,
8685
"archive_path" => SystemTextEncoding::toUTF8($archivePath)
87-
), $messages["compression.5"], true, 4);
86+
), $messages["compression.5"], true, 2);
8887
AJXP_XMLWriter::close();
8988
return null;
9089
} else {
9190
$maxAuthorizedSize = 4294967296;
9291
$currentDirUrlLength = strlen($currentDirUrl);
93-
$tabFolders = [];
94-
$tabAllRecursiveFiles = [];
95-
$tabFilesNames = [];
92+
$tabFolders = array();
93+
$tabAllRecursiveFiles = array();
94+
$tabFilesNames = array();
9695
foreach ($nodes as $node) {
9796
$nodeUrl = $node->getUrl();
9897
if (is_file($nodeUrl) && filesize($nodeUrl) < $maxAuthorizedSize) {
@@ -127,7 +126,7 @@ public function receiveAction($action, $httpVars, $fileVars)
127126
try {
128127
$archive->addFile(AJXP_MetaStreamWrapper::getRealFSReference($fullPath), $fileName);
129128
$counterCompression++;
130-
file_put_contents($progressCompressionFileName, sprintf($messages["compression.6"], ($counterCompression / count($tabAllFiles)) * 100 . " %"));
129+
file_put_contents($progressCompressionFileName, sprintf($messages["compression.6"], round(($counterCompression / count($tabAllFiles)) * 100, 2) . " %"));
131130
} catch (Exception $e) {
132131
unlink($tmpArchiveName);
133132
throw $e;
@@ -165,7 +164,7 @@ public function receiveAction($action, $httpVars, $fileVars)
165164
"repository_id" => $repository->getId(),
166165
"compression_id" => $compressionId,
167166
"archive_path" => SystemTextEncoding::toUTF8($archivePath)
168-
), $progressCompression, true, 3);
167+
), $progressCompression, true, 5);
169168
AJXP_XMLWriter::close();
170169
} else {
171170
$newNode = new AJXP_Node($userSelection->currentBaseUrl() . $archivePath);
@@ -181,7 +180,7 @@ public function receiveAction($action, $httpVars, $fileVars)
181180
elseif ($action == "extraction") {
182181
$fileArchive = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["file"]), AJXP_SANITIZE_DIRNAME);
183182
$fileArchive = substr(strrchr($fileArchive, DIRECTORY_SEPARATOR), 1);
184-
$authorizedExtension = ["tar" => 4, "gz" => 7, "bz2" => 8];
183+
$authorizedExtension = array("tar" => 4, "gz" => 7, "bz2" => 8);
185184
$acceptedArchive = false;
186185
$extensionLength = 0;
187186
$counterExtract = 0;
@@ -220,7 +219,7 @@ public function receiveAction($action, $httpVars, $fileVars)
220219
"extraction_id" => $extractId,
221220
"currentDirUrl" => $currentDirUrl,
222221
"onlyFileName" => $onlyFileName
223-
), $messages["compression.12"], true, 3);
222+
), $messages["compression.12"], true, 2);
224223
AJXP_XMLWriter::close();
225224
return null;
226225
}
@@ -240,7 +239,7 @@ public function receiveAction($action, $httpVars, $fileVars)
240239
$newNode = new AJXP_Node($currentDirUrl . $onlyFileName . DIRECTORY_SEPARATOR . $fileNameInArchive);
241240
AJXP_Controller::applyHook("node.change", array(null, $newNode, false));
242241
$counterExtract++;
243-
file_put_contents($progressExtractFileName, sprintf($messages["compression.12"], ($counterExtract / $archive->count()) * 100 . " %"));
242+
file_put_contents($progressExtractFileName, sprintf($messages["compression.12"], round(($counterExtract / $archive->count()) * 100, 2) . " %"));
244243
}
245244
} catch (Exception $e) {
246245
throw new AJXP_Exception($e);
@@ -258,7 +257,7 @@ public function receiveAction($action, $httpVars, $fileVars)
258257
"extraction_id" => $extractId,
259258
"currentDirUrl" => $currentDirUrl,
260259
"onlyFileName" => $onlyFileName
261-
), $progressExtract, true, 3);
260+
), $progressExtract, true, 5);
262261
AJXP_XMLWriter::close();
263262
} else {
264263
$newNode = new AJXP_Node($currentDirUrl . $onlyFileName);

core/src/plugins/action.compression/manifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
tmpFileName = name;
3636
compteurFileName = 1;
3737
}
38-
//METTRE EN ARRAY LE FOLDERS QUI ONT PRESQUE LE MEME NOM
3938
while(userSelection.fileNameExists(name + extension)){
4039
name = tmpFileName + "-" + compteurFileName;
4140
compteurFileName ++;
@@ -47,7 +46,7 @@
4746
var archiveTypeSelect = oForm.down('select[id="type_archive"]');
4847
var archiveExtension = archiveTypeSelect.getValue();
4948
if (userSelection.isUnique()) {
50-
archiveName = getBaseName(userSelection.getUniqueFileName());
49+
archiveName = getBaseName(userSelection.getUniqueFileName()).split(".").shift();
5150
} else if (crtDir.length == 1) {
5251
archiveName = "Archive";
5352
} else {

0 commit comments

Comments
 (0)