From 641577a9ce67f12a183e81bfb19fdb4c4f34a0ea Mon Sep 17 00:00:00 2001 From: Ray Nicholus Date: Tue, 10 Apr 2018 11:47:00 -0500 Subject: [PATCH] fix(various): misc areas where null values may cause problems (#1995) --- client/js/ajax.requester.js | 2 +- .../upload-handler/upload.handler.controller.js | 4 +++- client/js/upload-handler/xhr.upload.handler.js | 17 ++++++++++++----- client/js/uploader.basic.api.js | 2 +- client/js/version.js | 2 +- package.json | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/client/js/ajax.requester.js b/client/js/ajax.requester.js index fa1c174a3..5d7e91be4 100644 --- a/client/js/ajax.requester.js +++ b/client/js/ajax.requester.js @@ -91,7 +91,7 @@ qq.AjaxRequester = function(o) { // Returns either a new XHR/XDR instance, or an existing one for the associated `File` or `Blob`. function getXhrOrXdr(id, suppliedXhr) { - var xhrOrXdr = requestData[id].xhr; + var xhrOrXdr = requestData[id] && requestData[id].xhr; if (!xhrOrXdr) { if (suppliedXhr) { diff --git a/client/js/upload-handler/upload.handler.controller.js b/client/js/upload-handler/upload.handler.controller.js index 42facef4f..a8f8c2791 100644 --- a/client/js/upload-handler/upload.handler.controller.js +++ b/client/js/upload-handler/upload.handler.controller.js @@ -104,7 +104,9 @@ qq.UploadHandlerController = function(o, namespace) { chunked.reset(id); } else { - inProgressIdx = qq.indexOf(handler._getFileState(id).chunking.inProgress, chunkIdx); + var inProgressChunksArray = handler._getFileState(id).chunking.inProgress; + + inProgressIdx = inProgressChunksArray ? qq.indexOf(inProgressChunksArray, chunkIdx) : -1; if (inProgressIdx >= 0) { handler._getFileState(id).chunking.inProgress.splice(inProgressIdx, 1); handler._getFileState(id).chunking.remaining.unshift(chunkIdx); diff --git a/client/js/upload-handler/xhr.upload.handler.js b/client/js/upload-handler/xhr.upload.handler.js index 131b10690..967e0211f 100644 --- a/client/js/upload-handler/xhr.upload.handler.js +++ b/client/js/upload-handler/xhr.upload.handler.js @@ -88,7 +88,11 @@ qq.XhrUploadHandler = function(spec) { qq.extend(this, { // Clear the cached chunk `Blob` after we are done with it, just in case the `Blob` bytes are stored in memory. clearCachedChunk: function(id, chunkIdx) { - delete handler._getFileState(id).temp.cachedChunks[chunkIdx]; + var fileState = handler._getFileState(id); + + if (fileState) { + delete fileState.temp.cachedChunks[chunkIdx]; + } }, clearXhr: function(id, chunkIdx) { @@ -542,11 +546,14 @@ qq.XhrUploadHandler = function(spec) { _shouldChunkThisFile: function(id) { var state = handler._getFileState(id); - if (!state.chunking) { - handler.reevaluateChunking(id); - } + // file may no longer be available if it was recently cancelled + if (state) { + if (!state.chunking) { + handler.reevaluateChunking(id); + } - return state.chunking.enabled; + return state.chunking.enabled; + } } }); }; diff --git a/client/js/uploader.basic.api.js b/client/js/uploader.basic.api.js index 2984277a7..6eaf4919d 100644 --- a/client/js/uploader.basic.api.js +++ b/client/js/uploader.basic.api.js @@ -115,7 +115,7 @@ var uploadData = this._uploadData.retrieve({id: id}); if (uploadData && uploadData.status === qq.status.UPLOAD_FINALIZING) { - this.log(qq.format("Ignoring cancel for file ID {} ({}). Finalizing upload.", id, this.getName(id)), "error"); + this.log(qq.format("Ignoring cancel for file ID {} ({}). Finalizing upload.", id, this.getName(id)), "error"); } else { this._handler.cancel(id); diff --git a/client/js/version.js b/client/js/version.js index 499879a30..84692e112 100644 --- a/client/js/version.js +++ b/client/js/version.js @@ -1,2 +1,2 @@ /*global qq */ -qq.version = "5.16.0"; +qq.version = "5.16.1"; diff --git a/package.json b/package.json index 2c1376f3d..b45a17672 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "title": "Fine Uploader", "main": "lib/traditional.js", "types" : "typescript/fine-uploader.d.ts", - "version": "5.16.0", + "version": "5.16.1", "description": "Multiple file upload plugin with progress-bar, drag-and-drop, direct-to-S3 & Azure uploading, client-side image scaling, preview generation, form support, chunking, auto-resume, and tons of other features.", "keywords": [ "amazon",