@@ -41,13 +41,14 @@ require([
4141 if ( size <= 0 ) {
4242 return "0 MB" ;
4343 }
44- let log_level = Math . floor ( Math . log10 ( size ) ) ;
45- let byte_count = 12 ;
46- while ( log_level % byte_count >= log_level ) {
47- byte_count -= 3 ;
48- }
49- let bytes = ( Math . round ( ( size / ( Math . pow ( 10 , byte_count ) ) ) * 1000 ) / 1000 ) . toFixed ( 3 ) ;
50- return `${ bytes } ${ byte_level [ ( byte_count / 3 ) ] } ` ;
44+ let byte_count = 0 ;
45+ let converted_size = size ;
46+ while ( converted_size > 1024 ) {
47+ byte_count += 1 ;
48+ converted_size /= 1024 ;
49+ }
50+ let bytes = ( Math . round ( converted_size * 1000 ) / 1000 ) . toFixed ( 3 ) ;
51+ return `${ bytes } ${ byte_level [ byte_count ] } ` ;
5152 }
5253
5354 class DownloadProgressDisplay {
@@ -444,6 +445,8 @@ require([
444445 workerObjectURL = null ;
445446 workerLimit = navigator . hardwareConcurrency ;
446447
448+ lastProgressUpdate = - 1 ;
449+
447450 constructor ( ) {
448451 this . queues = new DownloadQueueManager ( ) ;
449452 this . workerCodeBlob = new Blob ( [ this . workerCode ] , { type : 'application/javascript' } ) ;
@@ -489,7 +492,11 @@ require([
489492 }
490493
491494 // Updates the current floating message contents and display class
495+ // Will abort out of an update if there isn't a pending cancellation and the last update time was < 2 seconds
496+ // ago
492497 progressUpdate ( message , progType ) {
498+ if ( this . lastProgressUpdate > 0 && Date . now ( ) - this . lastProgressUpdate < 1000 && ! this . pending_cancellation )
499+ return ;
493500 progType = progType || "download" ;
494501 let type = "info" ;
495502 let icon = progType || true ;
@@ -516,6 +523,7 @@ require([
516523 if ( ! this . pending_cancellation && this . in_progress > 0 ) {
517524 messages [ 'header' ] = this . all_requested ;
518525 }
526+ this . lastProgressUpdate = Date . now ( ) ;
519527 this . progressDisplay . update ( type , messages , icon ) ;
520528 }
521529
0 commit comments