Skip to content

Commit adf37a9

Browse files
chusoprroot
authored andcommitted
Chunk downloads seem not very useful for common users and it's confusing our users. Disable it.
1 parent 1d38b3b commit adf37a9

File tree

2 files changed

+1
-123
lines changed

2 files changed

+1
-123
lines changed

core/src/plugins/access.fs/class.fsAccessDriver.php

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -258,51 +258,6 @@ public function switchAction($action, $httpVars, $fileVars)
258258

259259
break;
260260

261-
case "prepare_chunk_dl" :
262-
263-
$chunkCount = intval($httpVars["chunk_count"]);
264-
$fileId = $this->urlBase.$selection->getUniqueFile();
265-
$sessionKey = "chunk_file_".md5($fileId.time());
266-
$totalSize = $this->filesystemFileSize($fileId);
267-
$chunkSize = intval ( $totalSize / $chunkCount );
268-
$realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $fileId, true);
269-
$chunkData = array(
270-
"localname" => basename($fileId),
271-
"chunk_count" => $chunkCount,
272-
"chunk_size" => $chunkSize,
273-
"total_size" => $totalSize,
274-
"file_id" => $sessionKey
275-
);
276-
277-
$_SESSION[$sessionKey] = array_merge($chunkData, array("file"=>$realFile));
278-
HTMLWriter::charsetHeader("application/json");
279-
print(json_encode($chunkData));
280-
281-
$node = $selection->getUniqueNode($this);
282-
AJXP_Controller::applyHook("node.read", array(&$node));
283-
284-
break;
285-
286-
case "download_chunk" :
287-
288-
$chunkIndex = intval($httpVars["chunk_index"]);
289-
$chunkKey = $httpVars["file_id"];
290-
$sessData = $_SESSION[$chunkKey];
291-
$realFile = $sessData["file"];
292-
$chunkSize = $sessData["chunk_size"];
293-
$offset = $chunkSize * $chunkIndex;
294-
if ($chunkIndex == $sessData["chunk_count"]-1) {
295-
// Compute the last chunk real length
296-
$chunkSize = $sessData["total_size"] - ($chunkSize * ($sessData["chunk_count"]-1));
297-
if (call_user_func(array($this->wrapperClassName, "isRemote"))) {
298-
register_shutdown_function("unlink", $realFile);
299-
}
300-
}
301-
$this->readFile($realFile, "force-download", $sessData["localname"].".".sprintf("%03d", $chunkIndex+1), false, false, true, $offset, $chunkSize);
302-
303-
304-
break;
305-
306261
case "compress" :
307262
// Make a temp zip and send it as download
308263
$loggedUser = AuthService::getLoggedUser();
@@ -1912,4 +1867,4 @@ function staticExtractArchiveItemPostCallback($status, $data){
19121867
function staticExtractArchiveItemPreCallback($status, $data){
19131868
return fsAccessDriver::$currentZipOperationHandler->extractArchiveItemPreCallback($status, $data);
19141869
}
1915-
}
1870+
}

core/src/plugins/access.fs/fsActions.xml

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -857,83 +857,6 @@
857857
</serverCallback>
858858
</processing>
859859
</action>
860-
<action name="prepare_chunk_dl">
861-
<rightsContext noUser="true" userLogged="only" read="true" write="false" adminOnly="false"/>
862-
<processing>
863-
<serverCallback methodName="switchAction" developerComment="Use the filesize of the file to generate an list of pieces to be downloaded using {download_chunk} action. Will generate a unique file_id to be used later.">
864-
<input_param description="Selected node" name="node" type="path" mandatory="true"/>
865-
<input_param description="Number of pieces to create for the file" name="chunk_count" type="integer"/>
866-
<output type="application/json"/>
867-
</serverCallback>
868-
</processing>
869-
</action>
870-
<action name="download_chunk">
871-
<gui text="397" title="398" src="download_manager.png" iconClass="icon-cloud-download" hasAccessKey="false">
872-
<context selection="true" dir="" recycle="false"
873-
actionBar="true" contextMenu="false" infoPanel="true" actionBarGroup="change">
874-
</context>
875-
<selectionContext dir="false" file="true" recycle="false" unique="true"/>
876-
</gui>
877-
<rightsContext noUser="true" userLogged="only" read="true" write="false" adminOnly=""/>
878-
<processing>
879-
<clientCallback prepareModal="true"><![CDATA[
880-
var userSelection = ajaxplorer.getUserSelection();
881-
882-
var loadFunc = function(oForm){
883-
var dObject = oForm.down('div[id="multiple_download_container"]');
884-
var legendDiv = oForm.down('div.dialogLegend');
885-
legendDiv.next("br").remove();
886-
legendDiv.update(MessageHash[399]+'<br>'+MessageHash[401]+'<a href="'+MessageHash[402]+'" target="_blank">'+MessageHash[402]+'</a>');
887-
dObject.insert({before:'\
888-
<div class="dialogButtons" id="chunk_dl_form" style="height:36px;"> \
889-
<span style="display:inline-block;float:left;margin-top: 11px;margin-left: 4px;margin-right: 4px;">'+MessageHash[400]+'</span> <input type="text" style="float:left;margin-top:5px; text-align:right; width:30px;height:24px;" name="chunk_count" id="chunk_count" value="4"> \
890-
<input type="image" style="float:left;" id="dl_form_submit" src="AJXP_THEME_FOLDER/images/actions/22/dialog_ok_apply.png" height="22" width="22" title="OK" class="dialogButton dialogFocus">\
891-
</div> \
892-
'});
893-
$("dl_form_submit").observe("click", function(e){
894-
Event.stop(e);
895-
var conn = new Connexion();
896-
conn.addParameter("get_action", "prepare_chunk_dl");
897-
conn.addParameter("chunk_count", $("chunk_count").value );
898-
conn.addParameter("file", userSelection.getUniqueNode().getPath());
899-
var downloader = new MultiDownloader(dObject, '');
900-
conn.onComplete = function(transp){
901-
var chunkData = transp.responseJSON;
902-
downloader.setDownloadUrl(ajxpServerAccessPath+'&action=download_chunk&file_id='+chunkData.file_id);
903-
downloader.triggerEnd = function(){hideLightBox();};
904-
for(var i=0; i<chunkData.chunk_count;i++){
905-
downloader.addListRow("&chunk_index=" + i, chunkData.localname + " (part " + (i + 1) + ")");
906-
}
907-
downloader.removeOnLoad();
908-
};
909-
downloader.setOnLoad();
910-
conn.sendAsync();
911-
});
912-
};
913-
var closeFunc = function(){
914-
hideLightBox();
915-
return false;
916-
};
917-
modal.showDialogForm('Download Multiple', 'multi_download_form', loadFunc, closeFunc, null, true);
918-
919-
]]></clientCallback>
920-
<clientForm id="multi_download_form"><![CDATA[
921-
<div id="multi_download_form" title="AJXP_MESSAGE[118]" box_width="345">
922-
<div class="dialogLegend">AJXP_MESSAGE[119]</div><br/>
923-
<div id="multiple_download_container"></div>
924-
<form style="display:inline;" action="index.php" method="GET" id="download_form" target="download_iframe">
925-
<input type="hidden" name="get_action" value="download">
926-
<input type="hidden" name="secure_token" value="">
927-
</form>
928-
<iframe id="download_iframe" name="download_iframe" style="display:none"></iframe>
929-
</div>]]>
930-
</clientForm>
931-
<serverCallback methodName="switchAction" developerComment="Chunk file into pieces before downloading the pieces. Can be handy for problematic and limited servers.">
932-
<input_param description="Unique key generated during the {prepare_chunk_dl} action." name="file_id" type="string"/>
933-
<input_param description="Position of the file to download" name="chunk_index" type="integer"/>
934-
</serverCallback>
935-
</processing>
936-
</action>
937860
<action name="purge">
938861
<processing>
939862
<serverCallback methodName="switchAction" developerComment="If the workspace has a PURGE configured parameter, finds the expired files and delete them. Can be typically called from command line."></serverCallback>

0 commit comments

Comments
 (0)