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

Commit

Permalink
Fix -> Now the quota is respected with jumploader (if you exceed it y…
Browse files Browse the repository at this point in the history
…ou will see the error in jumploader GUI and it will erase all the already uploaded partitions and it'll stop the upload)

Enhancement -> can now handle errors like missing partitions or corrupted data (you will see the error in jumploader GUI and it will erase all the already uploaded partitions and it'll stop the upload)
  • Loading branch information
thomasCresson committed Jul 1, 2013
1 parent dc2bac1 commit 2856b43
Showing 1 changed file with 49 additions and 10 deletions.
59 changes: 49 additions & 10 deletions core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
Expand Up @@ -77,24 +77,30 @@ public function postProcess($action, $httpVars, $postProcessData){

if(isset($postProcessData["processor_result"]["ERROR"])){
if(isset($httpVars["lastPartition"]) && isset($httpVars["partitionCount"])){
if($httpVars["partitionCount"] > 1){
/* we get the stream url (where all the partitions have been uploaded so far) */
$repository = ConfService::getRepository();
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$destStreamURL = $streamData["protocol"]."://".$repository->getId().$dir."/";
/* we get the stream url (where all the partitions have been uploaded so far) */
$repository = ConfService::getRepository();
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$destStreamURL = $streamData["protocol"]."://".$repository->getId().$dir."/";

if($httpVars["partitionCount"] > 1){
/* we fetch the information that help us to construct the temp files name */
$index = intval($httpVars["partitionIndex"]);
$fileId = $httpVars["fileId"];
$clientId = $httpVars["ajxp_sessid"];

/* deletion of all the partitions that have been uploaded */
for($i = 0; $i < $index; $i++){
unlink($destStreamURL."$clientId.$fileId.$i");
for($i = 0; $i < $httpVars["partitionCount"]; $i++){
if(file_exists($destStreamURL."$clientId.$fileId.$i")){
unlink($destStreamURL."$clientId.$fileId.$i");
}
}
}
else{
$fileName = $httpVars["fileName"];
unlink($destStreamURL.$fileName);
}
}
echo "Error: ".$postProcessData["processor_result"]["ERROR"]["MESSAGE"];
return;
Expand All @@ -111,7 +117,6 @@ public function postProcess($action, $httpVars, $postProcessData){
}

if($httpVars["lastPartition"]){

$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
Expand All @@ -122,6 +127,40 @@ public function postProcess($action, $httpVars, $postProcessData){
$subs = explode("/", $httpVars["relativePath"]);
$userfile_name = array_pop($subs);
$folderForbidden = false;
$all_in_place = true;
$partitions_length = 0;
$fileId = $httpVars["fileId"];
$clientId = $httpVars["ajxp_sessid"];
$partitionCount = $httpVars["partitionCount"];
$partitionIndex = $httpVars["partitionIndex"];
$fileLength = $_POST["fileLength"];

/* check if all the partitions have been uploaded or not */
for( $i = 0; $all_in_place && $i < $partitionCount; $i++ ) {
$partition_file = $destStreamURL."$clientId.$fileId.$i";
if( file_exists( $partition_file ) ) {
$partitions_length += filesize( $partition_file );
} else {
$all_in_place = false;
}
}

if(!$all_in_place || $partitions_length != intval($fileLength)){
echo "Error: Upload validation error!";
/* we delete all the uploaded partitions */
if($httpVars["partitionCount"] > 1){
for($i = 0; $i < $partitionCount; $i++){
if(file_exists($destStreamURL."$clientId.$fileId.$i")){
unlink($destStreamURL."$clientId.$fileId.$i");
}
}
}
else{
$fileName = $httpVars["fileName"];
unlink($destStreamURL.$fileName);
}
return;
}

if(count($subs) > 0){
$curDir = "";
Expand Down

0 comments on commit 2856b43

Please sign in to comment.