### Eclipse Workspace Patch 1.0 #P fluid-components Index: src/webapp/fluid-components/js/fluid/uploader/FileQueue.js =================================================================== --- src/webapp/fluid-components/js/fluid/uploader/FileQueue.js (revision 6476) +++ src/webapp/fluid-components/js/fluid/uploader/FileQueue.js (working copy) @@ -137,6 +137,7 @@ that.start = function () { that.queue.setupCurrentBatch(); that.queue.isUploading = true; + that.queue.stopUploadOnFileComplete = false; that.events.onUploadStart.fire(that.queue.currentBatch.files); }; @@ -153,7 +154,7 @@ }; that.shouldUploadNextFile = function () { - return that.queue.isUploading && that.queue.currentBatch.numFilesCompleted < that.queue.currentBatch.files.length; + return !that.queue.stopUploadOnFileComplete && that.queue.isUploading && that.queue.currentBatch.numFilesCompleted < that.queue.currentBatch.files.length; }; that.complete = function () { Index: src/webapp/fluid-components/js/fluid/uploader/Uploader.js =================================================================== --- src/webapp/fluid-components/js/fluid/uploader/Uploader.js (revision 6480) +++ src/webapp/fluid-components/js/fluid/uploader/Uploader.js (working copy) @@ -659,6 +659,7 @@ onQueueError: null, afterFileDialog: null, onUploadStart: null, + onUploadStop: null, onFileStart: null, onFileProgress: null, onFileError: null, Index: src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js =================================================================== --- src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js (revision 6480) +++ src/webapp/fluid-components/js/fluid/uploader/SWFUploadManager.js (working copy) @@ -219,11 +219,14 @@ } } - result.upload_complete_handler = function(file){ + result.upload_complete_handler = function (file) { that.queueManager.finishFile(file); if (that.queueManager.shouldUploadNextFile()) { that.swfUploader.startUpload(); } else { + if (that.queueManager.queue.stopUploadOnFileComplete) { + that.swfUploader.stopUpload(); + } that.queueManager.complete(); } }; @@ -243,6 +246,16 @@ that.swfUploader.selectFiles(); } }; + + /* FLUID-822: while stopping the upload cycle while a file is in mid-upload should be possible + * in practice, it sets up a state where when the upload cycle is restarted SWFUpload will get stuck + * therefor we only stop the upload after a file has completed but before the next file begins. + */ + + var stopUpload = function (that) { + that.queue.stopUploadOnFileComplete = true; + that.events.onUploadStop.fire(); + }; var bindEvents = function (that) { var fileStatusUpdater = function (file) { @@ -359,7 +372,7 @@ * Cancels an in-progress upload. */ that.stop = function () { - that.swfUploader.stopUpload(); + stopUpload(that); }; setupSwfUploadManager(that, events);