@@ -333,12 +333,7 @@ export class IDBMirrorVFS extends FacadeVFS {
333
333
334
334
if ( file . flags & VFS . SQLITE_OPEN_MAIN_DB ) {
335
335
if ( ! file . txActive ) {
336
- file . txActive = {
337
- path : file . path ,
338
- txId : file . viewTx . txId + 1 ,
339
- blocks : new Map ( ) ,
340
- fileSize : file . blockSize * file . blocks . size ,
341
- } ;
336
+ this . #createTx( file ) ;
342
337
}
343
338
file . txActive . blocks . set ( iOffset , pData . slice ( ) ) ;
344
339
file . txActive . fileSize = Math . max ( file . txActive . fileSize , iOffset + pData . byteLength ) ;
@@ -375,6 +370,9 @@ export class IDBMirrorVFS extends FacadeVFS {
375
370
const file = this . #mapIdToFile. get ( fileId ) ;
376
371
377
372
if ( file . flags & VFS . SQLITE_OPEN_MAIN_DB ) {
373
+ if ( ! file . txActive ) {
374
+ this . #createTx( file ) ;
375
+ }
378
376
file . txActive . fileSize = iSize ;
379
377
} else {
380
378
// All files that are not main databases are stored in a single
@@ -653,7 +651,7 @@ export class IDBMirrorVFS extends FacadeVFS {
653
651
}
654
652
}
655
653
656
- let truncated = tx . fileSize + file . blockSize ;
654
+ let truncated = tx . fileSize ;
657
655
while ( file . blocks . delete ( truncated ) ) {
658
656
truncated += file . blockSize ;
659
657
}
@@ -709,6 +707,18 @@ export class IDBMirrorVFS extends FacadeVFS {
709
707
file . txWriteHint = false ;
710
708
}
711
709
710
+ /**
711
+ * @param {File } file
712
+ */
713
+ #createTx( file ) {
714
+ file . txActive = {
715
+ path : file . path ,
716
+ txId : file . viewTx . txId + 1 ,
717
+ blocks : new Map ( ) ,
718
+ fileSize : file . blockSize * file . blocks . size ,
719
+ } ;
720
+ }
721
+
712
722
/**
713
723
* @param {File } file
714
724
*/
0 commit comments