From eee0121b10ac9e4d1aad7a8347d158d3c02fa4ba Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Sun, 17 Jul 2016 19:19:23 +0200 Subject: fix cancel uploads diff --git a/www/js/importer.js b/www/js/importer.js index 4c6ddb9..6579d4e 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -352,6 +352,8 @@ Rdxport.Upload = function(fileOrsourceUri, group, groupView, cartNumber, useMeta this.error = false; this.errorStatus = ''; this.errorString = ''; + + this.uploadInterval = null; }; Rdxport.Upload.prototype.isUploading = function() { @@ -384,7 +386,7 @@ Rdxport.Upload.prototype.onmessage = function(event) { this.groupView.uploadProgress(this); break; case Rdxport.Importer.TYPE_PROGRESS: - console.log(data); + //console.log(data); this.uploadprogress.current = data.CURRENT; this.uploadprogress.total = data.TOTAL; this.uploadprogress.progress = data.PROGRESS; @@ -418,7 +420,7 @@ Rdxport.Upload.prototype.onmessage = function(event) { var start = 0; var end = chunkSize; var self = this; - var interval = setInterval(function() { + this.uploadInterval = setInterval(function() { for(var i = 0; i < 16; i++) { if (self.webSocket.bufferedAmount > 16 * chunkSize) { return true; @@ -427,7 +429,7 @@ Rdxport.Upload.prototype.onmessage = function(event) { self.webSocket.send(blob); if (self.file.size === end) { - clearInterval(interval); + clearInterval(self.uploadInterval); return true; } start += chunkSize; @@ -501,6 +503,7 @@ Rdxport.Upload.prototype.close = function() { }; Rdxport.Upload.prototype.cancel = function() { + clearInterval(this.uploadInterval); this.webSocket.send(JSON.stringify({ COMMAND: 'cancel' })); }; -- cgit v0.10.2