made progress bars more accurate
authoruh_wot <3631986-uh_wot@users.noreply.gitlab.com>
Tue, 7 Apr 2020 21:37:31 +0000 (23:37 +0200)
committeruh_wot <3631986-uh_wot@users.noreply.gitlab.com>
Tue, 7 Apr 2020 21:37:31 +0000 (23:37 +0200)
app/app.js

index d0c41f1298c0cf1d11f6cb7e320135eb355bc656..549a5b9f5db96ac6f657c41697e3addf4e312b66 100644 (file)
@@ -2143,13 +2143,11 @@ io.sockets.on('connection', function (s) {
                        }
                        downloadQueue[queueId].percentage += 100/downloadQueue[queueId].size
                        if (Math.round(downloadQueue[queueId].percentage) != downloadQueue[queueId].lastPercentage) {
-                               if (Math.round(downloadQueue[queueId].percentage) % 5 == 0) {
-                                       downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
-                                       io.sockets.emit("downloadProgress", {
-                                               queueId: queueId,
-                                               percentage: downloadQueue[queueId].lastPercentage
-                                       })
-                               }
+                               downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
+                               io.sockets.emit("downloadProgress", {
+                                       queueId: queueId,
+                                       percentage: downloadQueue[queueId].lastPercentage
+                               })
                        }
                        return;
                }else{
@@ -2265,14 +2263,12 @@ io.sockets.on('connection', function (s) {
                                                                                if ((percentage - downloadQueue[queueId].percentage > 1) || (chunkLength == complete)) {
                                                                                        downloadQueue[queueId].percentage = percentage
                                                                                        if (Math.round(downloadQueue[queueId].percentage) != downloadQueue[queueId].lastPercentage) {
-                                                                                               if (Math.round(downloadQueue[queueId].percentage) % 5 == 0) {
-                                                                                                       downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
-                                                                                                       io.sockets.emit("downloadProgress", {
-                                                                                                               queueId: queueId,
-                                                                                                               percentage: downloadQueue[queueId].lastPercentage
-                                                                                                       })
-                                                                                                       //logger.info("Updating download progress to: " + downloadQueue[queueId].lastPercentage)
-                                                                                               }
+                                                                                               downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
+                                                                                               io.sockets.emit("downloadProgress", {
+                                                                                                       queueId: queueId,
+                                                                                                       percentage: downloadQueue[queueId].lastPercentage
+                                                                                               })
+                                                                                               //logger.info("Updating download progress to: " + downloadQueue[queueId].lastPercentage)
                                                                                        }
                                                                                }
                                                                        }catch(err){}
@@ -2293,14 +2289,12 @@ io.sockets.on('connection', function (s) {
                                                                                let chunkProgres = ((chunk.length / complete)) / downloadQueue[queueId].size * 100
                                                                                downloadQueue[queueId].percentage += chunkProgres
                                                                                if (Math.round(downloadQueue[queueId].percentage) != downloadQueue[queueId].lastPercentage) {
-                                                                                       if (Math.round(downloadQueue[queueId].percentage) % 5 == 0) {
-                                                                                               downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
-                                                                                               io.sockets.emit("downloadProgress", {
-                                                                                                       queueId: queueId,
-                                                                                                       percentage: downloadQueue[queueId].lastPercentage
-                                                                                               })
-                                                                                               //logger.info("Updating download progress to: " + downloadQueue[queueId].lastPercentage)
-                                                                                       }
+                                                                                       downloadQueue[queueId].lastPercentage = Math.round(downloadQueue[queueId].percentage)
+                                                                                       io.sockets.emit("downloadProgress", {
+                                                                                               queueId: queueId,
+                                                                                               percentage: downloadQueue[queueId].lastPercentage
+                                                                                       })
+                                                                                       //logger.info("Updating download progress to: " + downloadQueue[queueId].lastPercentage)
                                                                                }
                                                                        }catch(err){}
                                                                }