From 6c9e204043c286468190cf31598ef55e6d67db00 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 22 May 2020 17:24:28 -0500 Subject: [PATCH 1/9] add delay for tiny files --- src/main/webapp/resources/js/fileupload.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 3d31962b314..3a28ab3e4cf 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -49,7 +49,7 @@ function setupDirectUpload(enabled) { var callback = function(mutations) { mutations.forEach(function(mutation) { for(i=0; i Date: Thu, 28 May 2020 15:05:37 -0500 Subject: [PATCH 2/9] more changes to fix concurrency issues --- src/main/webapp/resources/js/fileupload.js | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 3a28ab3e4cf..7eae042455a 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -24,6 +24,8 @@ var finishFile = (function () { function setupDirectUpload(enabled) { if(enabled) { directUploadEnabled=true; + //An indicator as to which version is being used - should keep updated. + console.log('Dataverse Direct Upload v4.20-beta-2'); $('.ui-fileupload-upload').hide(); $('.ui-fileupload-cancel').hide(); //Catch files entered via upload dialog box. Since this 'select' widget is replaced by PF, we need to add a listener again when it is replaced @@ -120,7 +122,8 @@ async function startRequestForDirectUploadUrl() { requestDirectUploadUrl(); } -function uploadFileDirectly(url, storageId) { +async function uploadFileDirectly(url, storageId) { + await sleep(500); inDataverseCall=false; if(directUploadEnabled) { @@ -210,7 +213,7 @@ function reportUpload(storageId, file){ } async function handleDirectUpload(storageId, file, md5) { - //Wait for each call to finish and update the DOM + //Wait for each call to finish and update the DOM while(inDataverseCall === true) { await sleep(500); } @@ -218,7 +221,7 @@ async function handleDirectUpload(storageId, file, md5) { inDataverseCall=true; if(file.size < 1000) { //artificially slow reporting of the upload of tiny files to avoid problems with maintaining JSF state - await sleep(500); + // await sleep(500); } //storageId is not the location - has a : separator and no path elements from dataset //(String uploadComponentId, String fullStorageIdentifier, String fileName, String contentType, String checksumType, String checksumValue) @@ -278,8 +281,8 @@ function uploadFinished(fileupload) { } } -function directUploadFinished() { - inDataverseCall=false; +async function directUploadFinished() { + numDone = finishFile(); var total = curFile; var inProgress = filesInProgress; @@ -302,16 +305,22 @@ function directUploadFinished() { } } } + await sleep(500); + + inDataverseCall=false; } -function uploadFailure(jqXHR, upid, filename) { +async function uploadFailure(jqXHR, upid, filename) { // This handles HTTP errors (non-20x reponses) such as 0 (no connection at all), 413 (Request too large), // and 504 (Gateway timeout) where the upload call to the server fails (the server doesn't receive the request) // It notifies the user and provides info about the error (status, statusText) // On some browsers, the status is available in an event: window.event.srcElement.status // but others, (Firefox) don't support this. The calls below retrieve the status and other info // from the call stack instead (arguments to the fail() method that calls onerror() that calls this function - + + if(directUploadEnabled) { + await sleep(500); + } inDataverseCall=false; //Retrieve the error number (status) and related explanation (statusText) From 7b7e4419707a0c2101f2ca75917eb9fc86c14a4c Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 13:41:14 -0400 Subject: [PATCH 3/9] bug - requests for URL weren't queued after initial 4 --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 7eae042455a..e31993d21ef 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -301,7 +301,7 @@ async function directUploadFinished() { } else { if((inProgress < 4) && (inProgress < inList)) { filesInProgress= filesInProgress+1; - requestDirectUploadUrl(); + startRequestForDirectUploadUrl(); } } } From 6f9963fefd25e6b339cf634f610ffc391785b52c Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 15:13:52 -0400 Subject: [PATCH 4/9] update version console entry --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index e31993d21ef..c2583c2c3f7 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -25,7 +25,7 @@ function setupDirectUpload(enabled) { if(enabled) { directUploadEnabled=true; //An indicator as to which version is being used - should keep updated. - console.log('Dataverse Direct Upload v4.20-beta-2'); + console.log('Dataverse Direct Upload v4.20-beta-3'); $('.ui-fileupload-upload').hide(); $('.ui-fileupload-cancel').hide(); //Catch files entered via upload dialog box. Since this 'select' widget is replaced by PF, we need to add a listener again when it is replaced From e6a0fbfdf26adaca79092966ec6d7b9783598470 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 16:01:47 -0400 Subject: [PATCH 5/9] make it easier to adjust delay --- src/main/webapp/resources/js/fileupload.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index c2583c2c3f7..608cd563a3c 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -1,6 +1,7 @@ var fileList = []; var observer2=null; var numDone=0; +var delay=200; //milliseconds //true indicates direct upload is being used, but cancel may set it back to false at which point direct upload functions should not do further work var directUploadEnabled=false; @@ -114,7 +115,7 @@ function queueFileForDirectUpload(file) { async function startRequestForDirectUploadUrl() { //Wait for each call to finish and update the DOM while(inDataverseCall === true) { - await sleep(500); + await sleep(delay); } inDataverseCall=true; //storageId is not the location - has a : separator and no path elements from dataset @@ -123,7 +124,7 @@ async function startRequestForDirectUploadUrl() { } async function uploadFileDirectly(url, storageId) { - await sleep(500); + await sleep(delay); inDataverseCall=false; if(directUploadEnabled) { @@ -215,13 +216,13 @@ function reportUpload(storageId, file){ async function handleDirectUpload(storageId, file, md5) { //Wait for each call to finish and update the DOM while(inDataverseCall === true) { - await sleep(500); + await sleep(delay); } inDataverseCall=true; if(file.size < 1000) { //artificially slow reporting of the upload of tiny files to avoid problems with maintaining JSF state - // await sleep(500); + // await sleep(delay); } //storageId is not the location - has a : separator and no path elements from dataset //(String uploadComponentId, String fullStorageIdentifier, String fileName, String contentType, String checksumType, String checksumValue) @@ -305,7 +306,7 @@ async function directUploadFinished() { } } } - await sleep(500); + await sleep(delay); inDataverseCall=false; } @@ -319,7 +320,7 @@ async function uploadFailure(jqXHR, upid, filename) { // from the call stack instead (arguments to the fail() method that calls onerror() that calls this function if(directUploadEnabled) { - await sleep(500); + await sleep(delay); } inDataverseCall=false; From d79c1d13b58aa217fe1756c9e04d4032aea749c1 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 16:36:25 -0400 Subject: [PATCH 6/9] decrease to 100 ms delay keeping the cancel delay at 1 second - any queued uploads need to finish. --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 608cd563a3c..27899d53f7b 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -1,7 +1,7 @@ var fileList = []; var observer2=null; var numDone=0; -var delay=200; //milliseconds +var delay=100; //milliseconds //true indicates direct upload is being used, but cancel may set it back to false at which point direct upload functions should not do further work var directUploadEnabled=false; From 9a878772e3c67614ae814c7c37ac53e01b7093f6 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 16:38:10 -0400 Subject: [PATCH 7/9] correct save button selector for disbale during cancel --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 27899d53f7b..9a8b6e71fea 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -83,7 +83,7 @@ async function cancelDatasetCreate() { directUploadEnabled=false; while(curFile!=numDone) { $("#cancelCreate").prop('onclick', null).text("Cancel In Progress...").prop('disabled', true); - $("#datasetSave").prop('disabled', true); + $("#datasetForm:save").prop('disabled', true); await sleep(1000); } cancelCreateCommand(); From e736c4871df4633345e2b18451c79706ae2d547c Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 16:45:54 -0400 Subject: [PATCH 8/9] fix selector --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 9a8b6e71fea..142e6bb5f57 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -83,7 +83,7 @@ async function cancelDatasetCreate() { directUploadEnabled=false; while(curFile!=numDone) { $("#cancelCreate").prop('onclick', null).text("Cancel In Progress...").prop('disabled', true); - $("#datasetForm:save").prop('disabled', true); + $("#datasetForm\\:save").prop('disabled', true); await sleep(1000); } cancelCreateCommand(); From 5f3821e590294a37d87ab9ba9a72209e037887b8 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 5 Jun 2020 16:46:44 -0400 Subject: [PATCH 9/9] update console version info --- src/main/webapp/resources/js/fileupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index 142e6bb5f57..f485a8ca559 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -26,7 +26,7 @@ function setupDirectUpload(enabled) { if(enabled) { directUploadEnabled=true; //An indicator as to which version is being used - should keep updated. - console.log('Dataverse Direct Upload v4.20-beta-3'); + console.log('Dataverse Direct Upload for v5.0'); $('.ui-fileupload-upload').hide(); $('.ui-fileupload-cancel').hide(); //Catch files entered via upload dialog box. Since this 'select' widget is replaced by PF, we need to add a listener again when it is replaced