@@ -1449,10 +1449,24 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
1449
1449
1450
1450
for ( let path in this . config . only )
1451
1451
{
1452
+ const _path = p . join ( this . path , path ) ;
1453
+ const globalExtracting = getGlobalExtracting ( _path ) ;
1454
+
1455
+ if ( globalExtracting || fs . existsSync ( p . join ( this . tmp , path ) ) )
1456
+ {
1457
+ if ( globalExtracting ) await globalExtracting . promise ;
1458
+ this . whenExtractFile ( _path ) ;
1459
+ }
1460
+ else
1461
+ {
1462
+ setGlobalExtracting ( _path ) ;
1463
+ only . push ( path ) ;
1464
+ }
1465
+
1452
1466
if ( ! fs . existsSync ( p . join ( this . tmp , path ) ) )
1453
1467
only . push ( path ) ;
1454
1468
else
1455
- this . whenExtractFile ( p . join ( this . path , path ) ) ;
1469
+ this . whenExtractFile ( _path ) ;
1456
1470
}
1457
1471
1458
1472
if ( ! only . length )
@@ -1475,13 +1489,18 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
1475
1489
{
1476
1490
let file = files [ i ] ;
1477
1491
1478
- if ( fs . existsSync ( p . join ( this . tmp , file . pathInCompressed ) ) )
1492
+ const _path = p . join ( this . path , file . pathInCompressed ) ;
1493
+ const globalExtracting = getGlobalExtracting ( _path ) ;
1494
+
1495
+ if ( globalExtracting || fs . existsSync ( p . join ( this . tmp , file . pathInCompressed ) ) )
1479
1496
{
1480
- this . whenExtractFile ( p . join ( this . path , file . pathInCompressed ) ) ;
1497
+ if ( globalExtracting ) await globalExtracting . promise ;
1498
+ this . whenExtractFile ( _path ) ;
1481
1499
someIsExtracted = true ;
1482
1500
}
1483
1501
else
1484
1502
{
1503
+ setGlobalExtracting ( _path ) ;
1485
1504
only . push ( file . pathInCompressed ) ;
1486
1505
}
1487
1506
}
@@ -1700,6 +1719,7 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
1700
1719
compressed : this . isCompressed ( name ) ,
1701
1720
} ;
1702
1721
1722
+ globalWhenExtractFile ( path ) ;
1703
1723
this . callbackWhenFileExtracted ( file ) ;
1704
1724
}
1705
1725
@@ -2719,6 +2739,48 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
2719
2739
2720
2740
}
2721
2741
2742
+ var extractingPromises = { } ;
2743
+ var extractingPromisesST = { } ;
2744
+
2745
+ function setGlobalExtracting ( path )
2746
+ {
2747
+ extractingPromisesST [ path ] = setTimeout ( function ( ) {
2748
+
2749
+ globalWhenExtractFile ( path ) ;
2750
+
2751
+ } , 60000 ) ;
2752
+
2753
+ let _resolve = false ;
2754
+
2755
+ extractingPromises [ path ] = {
2756
+ promise : new Promise ( async function ( resolve , reject ) {
2757
+
2758
+ _resolve = resolve ;
2759
+
2760
+ } ) ,
2761
+ resolve : false ,
2762
+ } ;
2763
+
2764
+ extractingPromises [ path ] . resolve = _resolve ;
2765
+ }
2766
+
2767
+ function getGlobalExtracting ( path )
2768
+ {
2769
+ return extractingPromises [ path ] || false ;
2770
+ }
2771
+
2772
+ function globalWhenExtractFile ( path )
2773
+ {
2774
+ if ( extractingPromisesST [ path ] ) clearTimeout ( extractingPromisesST [ path ] ) ;
2775
+
2776
+ if ( extractingPromises [ path ] )
2777
+ {
2778
+ const globalExtracting = extractingPromises [ path ] ;
2779
+ delete extractingPromises [ path ] ;
2780
+ globalExtracting . resolve ( ) ;
2781
+ }
2782
+ }
2783
+
2722
2784
// Use this to remove generated vector images if window.devicePixelRatio is changed
2723
2785
async function removeTmpVector ( )
2724
2786
{
0 commit comments