@@ -1679,6 +1679,26 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
1679
1679
1680
1680
}
1681
1681
1682
+ this . stackOnlyInTasks = function ( only , stackSize = 500 ) {
1683
+
1684
+ const tasks = [ ] ;
1685
+
1686
+ if ( only )
1687
+ {
1688
+ for ( let i = 0 , len = Math . ceil ( only . length / stackSize ) ; i < len ; i ++ )
1689
+ {
1690
+ tasks . push ( only . slice ( i * stackSize , i * stackSize + stackSize ) ) ;
1691
+ }
1692
+
1693
+ return tasks ;
1694
+ }
1695
+ else
1696
+ {
1697
+ return [ only ] ;
1698
+ }
1699
+
1700
+ }
1701
+
1682
1702
this . fixCorruptedName = function ( name , pos = 0 ) {
1683
1703
1684
1704
if ( / � / . test ( name ) )
@@ -1918,58 +1938,76 @@ var fileCompressed = function(path, _realPath = false, forceType = false, prefix
1918
1938
let only = this . config . only ;
1919
1939
let _this = this ;
1920
1940
1921
- let _7z = await this . open7z ( true , this . config . _only || false ) ;
1922
- let extractedSome = false ;
1941
+ const onlyLen = this . config . _only ? this . config . _only . length : false ;
1942
+ const tasks = this . stackOnlyInTasks ( this . config . _only || false , 500 ) ;
1923
1943
1924
- return new Promise ( function ( resolve , reject ) {
1944
+ let result = false ;
1945
+ let error = false ;
1925
1946
1926
- _7z . on ( 'data' , function ( data ) {
1947
+ this . progressIndex = 1 ;
1927
1948
1928
- let extract = data . status == 'extracted' ? true : false ;
1949
+ for ( let i = 0 , len = tasks . length ; i < len ; i ++ )
1950
+ {
1951
+ const onlyStack = tasks [ i ] ;
1929
1952
1930
- if ( extract )
1931
- {
1932
- let name = _this . removeTmp ( p . normalize ( data . file ) ) ;
1953
+ const _7z = await this . open7z ( true , onlyStack ) ;
1954
+ let extractedSome = false ;
1933
1955
1934
- _this . setFileStatus ( name , { extracted : extract } ) ;
1935
- _this . whenExtractFile ( p . join ( _this . path , name ) ) ;
1956
+ result = await new Promise ( function ( resolve , reject ) {
1936
1957
1937
- extractedSome = true ;
1938
- }
1958
+ _7z . on ( 'data' , function ( data ) {
1939
1959
1940
- } ) . on ( 'progress' , function ( progress ) {
1960
+ let extract = data . status == 'extracted' ? true : false ;
1941
1961
1942
- _this . setProgress ( progress . percent / 100 ) ;
1962
+ if ( extract )
1963
+ {
1964
+ let name = _this . removeTmp ( p . normalize ( data . file ) ) ;
1943
1965
1944
- } ) . on ( 'end' , function ( data ) {
1966
+ _this . setFileStatus ( name , { extracted : extract } ) ;
1967
+ _this . whenExtractFile ( p . join ( _this . path , name ) ) ;
1945
1968
1946
- console . timeEnd ( 'extract7z: ' + _this . path ) ;
1969
+ extractedSome = true ;
1947
1970
1948
- _this . setProgress ( 1 ) ;
1971
+ _this . setProgress ( _this . progressIndex ++ / onlyLen ) ;
1972
+ }
1949
1973
1950
- console . log ( 'extract7z end: ' + _this . path ) ;
1974
+ } ) . on ( 'progress' , function ( progress ) {
1951
1975
1952
- resolve ( ) ;
1976
+ if ( ! onlyLen )
1977
+ _this . setProgress ( progress . percent / 100 ) ;
1953
1978
1954
- } ) . on ( 'error ' , function ( error ) {
1979
+ } ) . on ( 'end ' , function ( data ) {
1955
1980
1956
- if ( extractedSome )
1957
- {
1958
- /*_this.setProgress(1);
1959
- resolve();*/
1981
+ resolve ( ) ;
1960
1982
1961
- _this . saveErrorToCache ( error ) ;
1962
- dom . compressedError ( error , false , sha1 ( _this . path ) ) ;
1963
- }
1964
- else
1965
- {
1966
- resolve ( _this . extractIfTypeFromBinaryIsDifferent ( error ) ) ;
1967
- }
1983
+ } ) . on ( 'error' , function ( error ) {
1984
+
1985
+ if ( extractedSome )
1986
+ {
1987
+ /*_this.setProgress(1);
1988
+ resolve();*/
1989
+
1990
+ _this . saveErrorToCache ( error ) ;
1991
+ dom . compressedError ( error , false , sha1 ( _this . path ) ) ;
1992
+ }
1993
+ else
1994
+ {
1995
+ error = true ;
1996
+ resolve ( _this . extractIfTypeFromBinaryIsDifferent ( error ) ) ;
1997
+ }
1998
+
1999
+ } ) ;
1968
2000
1969
2001
} ) ;
1970
2002
1971
- } ) ;
1972
-
2003
+ if ( error ) return result ;
2004
+ }
2005
+
2006
+ this . setProgress ( 1 ) ;
2007
+
2008
+ console . timeEnd ( 'extract7z: ' + _this . path ) ;
2009
+
2010
+ return result ;
1973
2011
}
1974
2012
1975
2013
0 commit comments