File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,26 +95,24 @@ var Storage = (() => {
9595 for ( let k of Object . keys ( keys ) ) {
9696 let s = JSON . stringify ( keys [ k ] ) ;
9797 let chunksCountKey = chunksKey ( k ) ;
98- let oldCount = await browser . storage . sync . get ( chunksCountKey ) [ chunksCountKey ] || 0 ;
98+ let oldCount = ( await browser . storage . sync . get ( chunksCountKey ) ) [ chunksCountKey ] || 0 ;
9999 let count ;
100100 if ( s . length > MAX_ITEM_SIZE ) {
101101 count = Math . ceil ( s . length / MAX_ITEM_SIZE ) ;
102102 let chunks = {
103103 [ chunksCountKey ] : count
104104 } ;
105- for ( let j = 0 , o = 0 ; j < count ; ++ j , o += MAX_ITEM_SIZE ) {
106- chunks [ `${ k } /${ j } ` ] = s . substr ( o , MAX_ITEM_SIZE ) ;
105+ for ( let j = 0 , offset = 0 ; j < count ; ++ j ) {
106+ chunks [ `${ k } /${ j } ` ] = s . substring ( offset , offset += MAX_ITEM_SIZE ) ;
107107 }
108108 await browser . storage . sync . set ( chunks ) ;
109109 keys [ k ] = "[CHUNKED]" ;
110110 } else {
111111 count = 0 ;
112112 removeKeys . push ( chunksCountKey ) ;
113113 }
114- if ( oldCount -- > count ) {
115- do {
116- removeKeys . push ( `${ k } ${ oldCount } ` ) ;
117- } while ( oldCount -- > count ) ;
114+ while ( oldCount -- > count ) {
115+ removeKeys . push ( `${ k } /${ oldCount } ` ) ;
118116 }
119117 }
120118 await browser . storage . sync . remove ( removeKeys ) ;
You can’t perform that action at this time.
0 commit comments