From 7f40de1c76deea24afa96bb3c5f681ee64e55bf5 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 20 Jun 2025 03:54:28 +0100 Subject: [PATCH] yesh --- vg_console.c | 10 ++++++++-- vg_db.c | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vg_console.c b/vg_console.c index cd744df..7aa5352 100644 --- a/vg_console.c +++ b/vg_console.c @@ -636,8 +636,14 @@ static int vg_console_exec( int argc, const char *argv[] ) while( fgets( line, sizeof( line ), fp ) ) { line[ strcspn( line, "\r\n#" ) ] = 0x00; - if( line[0] != 0x00 ) - vg_execute_console_input( line, silent, 0 ); + if( line[0] == 0x00 ) + continue; + + if( line[0] == '/' ) + if( line[1] == '/' ) + continue; + + vg_execute_console_input( line, silent, 0 ); } fclose( fp ); diff --git a/vg_db.c b/vg_db.c index 2656bf5..f4e3a76 100644 --- a/vg_db.c +++ b/vg_db.c @@ -102,15 +102,18 @@ static void vg_db_commit( vg_db *db, FILE *fwal ) if( last_good_log != last_good_checkpoint ) vg_warn( "Rewinding...\n" ); + u32 writes_away = 0; u64 rewind_cur = last_good_log; while( rewind_cur != last_good_checkpoint ) { + writes_away ++; if( fseek( fwal, rewind_cur, SEEK_SET ) ) vg_db_abort( db, "While rewinding WAL, SEEK_SET(0x%lx) failed\n", rewind_cur ); if( !fread( &log, sizeof(log), 1, fwal ) ) vg_db_abort( db, "While rewinding WAL, fread failed\n" ); if( fread( temp_page, log.data_size, 1, fwal ) ) { + vg_info( "Offset: %lx, size: %lu\n", log.db_file_offset, log.data_size ); if( fseek( db->fp, log.db_file_offset, SEEK_SET ) ) vg_db_abort( db, "While rewinding WAL, SEEK_SET(0x%lx) failed\n", log.db_file_offset ); if( !fwrite( temp_page, log.data_size, 1, db->fp ) ) @@ -124,6 +127,9 @@ static void vg_db_commit( vg_db *db, FILE *fwal ) } } + if( last_good_log != last_good_checkpoint ) + vg_info( "Rewinding took %u writes back..\n", writes_away ); + free( temp_page ); } -- 2.25.1