diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-06-29 17:40:26 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-06-29 17:41:16 (GMT) |
commit | b79e536f5333102aa746656a6878890e4b3f3a96 (patch) | |
tree | daca904acfb08f57bb29eb5573cba708b32f39e8 | |
parent | 06bd47c0bed25779d679eab1385b74345f7f153b (diff) |
speedup for local uploads over websockets
-rw-r--r-- | www/js/importer.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/www/js/importer.js b/www/js/importer.js index dd8913f..1da9d1a 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -374,18 +374,21 @@ Rdxport.Upload.prototype.onmessage = function(event) { var end = chunkSize; var self = this; var interval = setInterval(function() { - if (self.webSocket.bufferedAmount > 4 * chunkSize) { - return true; - } - var blob = self.file.slice(start, end, {type: "application/octet-stream"}); - self.webSocket.send(blob); + for(var i = 0; i < 16; i++) { + if (self.webSocket.bufferedAmount > 16 * chunkSize) { + return true; + } + var blob = self.file.slice(start, end, {type: "application/octet-stream"}); + self.webSocket.send(blob); - if (self.file.size === end) { - clearInterval(interval); + if (self.file.size === end) { + clearInterval(interval); + return true; + } + start += chunkSize; + end += chunkSize; + end = end > self.file.size ? self.file.size : end; } - start += chunkSize; - end += chunkSize; - end = end > self.file.size ? self.file.size : end; }, 10); } }; |