@@ -55,7 +55,7 @@ const REG_ROUTESTATIC = /^(\/\/|https\:|http\:)+/g;
5555const REG_EMPTY = / \s / g;
5656const REG_SANITIZE_BACKSLASH = / \/ \/ / g;
5757const REG_WEBSOCKET_ERROR = / E C O N N R E S E T | E H O S T U N R E A C H | E P I P E | i s c l o s e d / gi;
58- const REG_SCRIPTCONTENT = / \< | \> | ; / g ;
58+ const REG_SCRIPTCONTENT = / \< | \> | ; / ;
5959const REQUEST_PROXY_FLAGS = [ 'post' , 'json' ] ;
6060const EMPTYARRAY = [ ] ;
6161const EMPTYOBJECT = { } ;
@@ -13959,12 +13959,13 @@ function Backup() {
1395913959 this . file = [ ] ;
1396013960 this . directory = [ ] ;
1396113961 this . path = '' ;
13962- this . fileName = '' ;
13963- this . read = { key : '' , value : '' , status : 0 } ;
13962+ this . read = { key : new Buffer ( 0 ) , value : new Buffer ( 0 ) , status : 0 } ;
1396413963 this . pending = 0 ;
1396513964 this . cache = { } ;
13966- this . complete = function ( ) { } ;
13965+ this . complete = NOOP ;
1396713966 this . filter = ( ) => true ;
13967+ this . bufKey = new Buffer ( ':' ) ;
13968+ this . bufNew = new Buffer ( '\n' ) ;
1396813969}
1396913970
1397013971Backup . prototype . restoreKey = function ( data ) {
@@ -13981,21 +13982,21 @@ Backup.prototype.restoreKey = function(data) {
1398113982 var tmp = data ;
1398213983
1398313984 if ( read . status === 2 ) {
13984- tmp = read . key + tmp ;
13985- index = tmp . indexOf ( ':' ) ;
13986- }
13987- else
13988- index = tmp . indexOf ( ':' ) ;
13985+ tmp = Buffer . concat ( [ read . key , tmp ] ) ;
13986+ index = tmp . indexOf ( self . bufKey ) ;
13987+ } else
13988+ index = tmp . indexOf ( self . bufKey ) ;
1398913989
1399013990 if ( index === - 1 ) {
13991- read . key += data ;
13991+ read . key = Buffer . concat ( [ read . key , data ] ) ;
1399213992 read . status = 2 ;
1399313993 return ;
1399413994 }
1399513995
1399613996 read . status = 1 ;
13997- read . key = tmp . substring ( 0 , index ) ;
13998- self . restoreValue ( tmp . substring ( index + 1 ) ) ;
13997+ read . key = tmp . slice ( 0 , index ) ;
13998+ self . restoreValue ( tmp . slice ( index + 1 ) ) ;
13999+ tmp = null ;
1399914000} ;
1400014001
1400114002Backup . prototype . restoreValue = function ( data ) {
@@ -14008,20 +14009,20 @@ Backup.prototype.restoreValue = function(data) {
1400814009 return ;
1400914010 }
1401014011
14011- var index = data . indexOf ( '\n' ) ;
14012+ var index = data . indexOf ( self . bufNew ) ;
1401214013 if ( index === - 1 ) {
1401314014 read . value += data ;
1401414015 return ;
1401514016 }
1401614017
14017- read . value += data . substring ( 0 , index ) ;
14018- self . restoreFile ( read . key . replace ( REG_EMPTY , '' ) , read . value . replace ( REG_EMPTY , '' ) ) ;
14018+ read . value = Buffer . concat ( [ read . value , data . slice ( 0 , index ) ] ) ;
14019+ self . restoreFile ( read . key . toString ( 'utf8' ) . replace ( REG_EMPTY , '' ) , read . value . toString ( 'utf8' ) . replace ( REG_EMPTY , '' ) ) ;
1401914020
1402014021 read . status = 0 ;
14021- read . value = '' ;
14022- read . key = '' ;
14022+ read . value = new Buffer ( 0 ) ;
14023+ read . key = new Buffer ( 0 ) ;
1402314024
14024- self . restoreKey ( data . substring ( index + 1 ) ) ;
14025+ self . restoreKey ( data . slice ( index + 1 ) ) ;
1402514026} ;
1402614027
1402714028Backup . prototype . restore = function ( filename , path , callback , filter ) {
@@ -14040,7 +14041,7 @@ Backup.prototype.restore = function(filename, path, callback, filter) {
1404014041 self . path = path ;
1404114042
1404214043 var stream = fs . createReadStream ( filename ) ;
14043- stream . on ( 'data' , buffer => self . restoreKey ( buffer . toString ( 'utf8' ) ) ) ;
14044+ stream . on ( 'data' , buffer => self . restoreKey ( buffer ) ) ;
1404414045
1404514046 if ( ! callback ) {
1404614047 stream . resume ( ) ;
@@ -14087,8 +14088,7 @@ Backup.prototype.restoreFile = function(key, value) {
1408714088 var buffer = new Buffer ( value , 'base64' ) ;
1408814089 self . pending ++ ;
1408914090 zlib . gunzip ( buffer , function ( err , data ) {
14090- fs . writeFileSync ( path . join ( self . path , key ) , data ) ;
14091- self . pending -- ;
14091+ fs . writeFile ( path . join ( self . path , key ) , data , ( ) => self . pending -- ) ;
1409214092 buffer = null ;
1409314093 } ) ;
1409414094} ;
@@ -14121,12 +14121,8 @@ Backup.prototype.createDirectory = function(p, root) {
1412114121 if ( is && arr [ 0 ] . indexOf ( ':' ) !== - 1 )
1412214122 arr . shift ( ) ;
1412314123
14124- var length = arr . length ;
14125-
14126- for ( var i = 0 ; i < length ; i ++ ) {
14127-
14124+ for ( var i = 0 , length = arr . length ; i < length ; i ++ ) {
1412814125 var name = arr [ i ] ;
14129-
1413014126 if ( is )
1413114127 directory += ( directory ? '\\' : '' ) + name ;
1413214128 else
0 commit comments