Skip to content

Commit b4eddc3

Browse files
committed
Chunk downloads seem not very useful for common users and it's confusing our users. Disable it.
1 parent 624c794 commit b4eddc3

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
@@ -315,51 +315,6 @@ public function switchAction($action, $httpVars, $fileVars)
315315

316316
break;
317317

318-
case "prepare_chunk_dl" :
319-
320-
$chunkCount = intval($httpVars["chunk_count"]);
321-
$fileId = $this->urlBase.$selection->getUniqueFile();
322-
$sessionKey = "chunk_file_".md5($fileId.time());
323-
$totalSize = $this->filesystemFileSize($fileId);
324-
$chunkSize = intval ( $totalSize / $chunkCount );
325-
$realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $fileId, true);
326-
$chunkData = array(
327-
"localname" => basename($fileId),
328-
"chunk_count" => $chunkCount,
329-
"chunk_size" => $chunkSize,
330-
"total_size" => $totalSize,
331-
"file_id" => $sessionKey
332-
);
333-
334-
$_SESSION[$sessionKey] = array_merge($chunkData, array("file"=>$realFile));
335-
HTMLWriter::charsetHeader("application/json");
336-
print(json_encode($chunkData));
337-
338-
$node = $selection->getUniqueNode($this);
339-
AJXP_Controller::applyHook("node.read", array(&$node));
340-
341-
break;
342-
343-
case "download_chunk" :
344-
345-
$chunkIndex = intval($httpVars["chunk_index"]);
346-
$chunkKey = $httpVars["file_id"];
347-
$sessData = $_SESSION[$chunkKey];
348-
$realFile = $sessData["file"];
349-
$chunkSize = $sessData["chunk_size"];
350-
$offset = $chunkSize * $chunkIndex;
351-
if ($chunkIndex == $sessData["chunk_count"]-1) {
352-
// Compute the last chunk real length
353-
$chunkSize = $sessData["total_size"] - ($chunkSize * ($sessData["chunk_count"]-1));
354-
if (call_user_func(array($this->wrapperClassName, "isRemote"))) {
355-
register_shutdown_function("unlink", $realFile);
356-
}
357-
}
358-
$this->readFile($realFile, "force-download", $sessData["localname"].".".sprintf("%03d", $chunkIndex+1), false, false, true, $offset, $chunkSize);
359-
360-
361-
break;
362-
363318
case "compress" :
364319
// Make a temp zip and send it as download
365320
$loggedUser = AuthService::getLoggedUser();
@@ -2057,4 +2012,4 @@ function staticExtractArchiveItemPostCallback($status, $data){
20572012
function staticExtractArchiveItemPreCallback($status, $data){
20582013
return fsAccessDriver::$currentZipOperationHandler->extractArchiveItemPreCallback($status, $data);
20592014
}
2060-
}
2015+
}

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

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -887,83 +887,6 @@
887887
</serverCallback>
888888
</processing>
889889
</action>
890-
<action name="prepare_chunk_dl">
891-
<rightsContext noUser="true" userLogged="only" read="true" write="false" adminOnly="false"/>
892-
<processing>
893-
<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.">
894-
<input_param description="Selected node" name="node" type="path" mandatory="true"/>
895-
<input_param description="Number of pieces to create for the file" name="chunk_count" type="integer"/>
896-
<output type="application/json"/>
897-
</serverCallback>
898-
</processing>
899-
</action>
900-
<action name="download_chunk">
901-
<gui text="397" title="398" src="download_manager.png" iconClass="icon-cloud-download" hasAccessKey="false">
902-
<context selection="true" dir="" recycle="false"
903-
actionBar="true" contextMenu="false" infoPanel="true" actionBarGroup="change">
904-
</context>
905-
<selectionContext dir="false" file="true" recycle="false" unique="true"/>
906-
</gui>
907-
<rightsContext noUser="true" userLogged="only" read="true" write="false" adminOnly=""/>
908-
<processing>
909-
<clientCallback prepareModal="true"><![CDATA[
910-
var userSelection = ajaxplorer.getUserSelection();
911-
912-
var loadFunc = function(oForm){
913-
var dObject = oForm.down('div[id="multiple_download_container"]');
914-
var legendDiv = oForm.down('div.dialogLegend');
915-
legendDiv.next("br").remove();
916-
legendDiv.update(MessageHash[399]+'<br>'+MessageHash[401]+'<a href="'+MessageHash[402]+'" target="_blank">'+MessageHash[402]+'</a>');
917-
dObject.insert({before:'\
918-
<div class="dialogButtons" id="chunk_dl_form" style="height:36px;"> \
919-
<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"> \
920-
<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">\
921-
</div> \
922-
'});
923-
$("dl_form_submit").observe("click", function(e){
924-
Event.stop(e);
925-
var conn = new Connexion();
926-
conn.addParameter("get_action", "prepare_chunk_dl");
927-
conn.addParameter("chunk_count", $("chunk_count").value );
928-
conn.addParameter("file", userSelection.getUniqueNode().getPath());
929-
var downloader = new MultiDownloader(dObject, '');
930-
conn.onComplete = function(transp){
931-
var chunkData = transp.responseJSON;
932-
downloader.setDownloadUrl(ajxpServerAccessPath+'&action=download_chunk&file_id='+chunkData.file_id);
933-
downloader.triggerEnd = function(){hideLightBox();};
934-
for(var i=0; i<chunkData.chunk_count;i++){
935-
downloader.addListRow("&chunk_index=" + i, chunkData.localname + " (part " + (i + 1) + ")");
936-
}
937-
downloader.removeOnLoad();
938-
};
939-
downloader.setOnLoad();
940-
conn.sendAsync();
941-
});
942-
};
943-
var closeFunc = function(){
944-
hideLightBox();
945-
return false;
946-
};
947-
modal.showDialogForm('Download Multiple', 'multi_download_form', loadFunc, closeFunc, null, true);
948-
949-
]]></clientCallback>
950-
<clientForm id="multi_download_form"><![CDATA[
951-
<div id="multi_download_form" title="AJXP_MESSAGE[118]" box_width="345">
952-
<div class="dialogLegend">AJXP_MESSAGE[119]</div><br/>
953-
<div id="multiple_download_container"></div>
954-
<form style="display:inline;" action="index.php" method="GET" id="download_form" target="download_iframe">
955-
<input type="hidden" name="get_action" value="download">
956-
<input type="hidden" name="secure_token" value="">
957-
</form>
958-
<iframe id="download_iframe" name="download_iframe" style="display:none"></iframe>
959-
</div>]]>
960-
</clientForm>
961-
<serverCallback methodName="switchAction" developerComment="Chunk file into pieces before downloading the pieces. Can be handy for problematic and limited servers.">
962-
<input_param description="Unique key generated during the {prepare_chunk_dl} action." name="file_id" type="string"/>
963-
<input_param description="Position of the file to download" name="chunk_index" type="integer"/>
964-
</serverCallback>
965-
</processing>
966-
</action>
967890
<action name="purge">
968891
<processing>
969892
<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)