File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -329,8 +329,9 @@ export class ShardedWal<T extends WalRecord = WalRecord> {
329329 }
330330
331331 const groupDir = path . join ( this . #dir, this . groupId ) ;
332- // create dir if not existing
333- ensureDirectoryExistsSync ( groupDir ) ;
332+ if ( ! fs . existsSync ( groupDir ) ) {
333+ return [ ] ;
334+ }
334335
335336 return fs
336337 . readdirSync ( groupDir )
@@ -358,18 +359,18 @@ export class ShardedWal<T extends WalRecord = WalRecord> {
358359 // Ensure base directory exists before calling shardFiles()
359360 ensureDirectoryExistsSync ( this . #dir) ;
360361
361- const fileRecoveries = this . shardFiles ( ) . map ( f => ( {
362+ const lastRecovery = this . shardFiles ( ) . map ( f => ( {
362363 file : f ,
363364 result : new WriteAheadLogFile ( {
364365 file : f ,
365366 codec : this . #format. codec ,
366367 } ) . recover ( ) ,
367368 } ) ) ;
368369
369- const records = fileRecoveries . flatMap ( ( { result } ) => result . records ) ;
370+ const records = lastRecovery . flatMap ( ( { result } ) => result . records ) ;
370371
371372 if ( this . #debug) {
372- this . #lastRecovery = fileRecoveries ;
373+ this . #lastRecovery = lastRecovery ;
373374 }
374375
375376 ensureDirectoryExistsSync ( path . dirname ( this . getFinalFilePath ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments