@@ -80,7 +80,7 @@ var relayInfo = {
8080 contact : "lux@fed.wtf" ,
8181 supported_nips : [ 1 , 2 , 4 , 5 , 9 , 11 , 12 , 13 , 15 , 16 , 17 , 20 , 22 , 25 , 28 , 33 , 40 , 42 , 57 ] ,
8282 software : "https://github.com/Spl0itable/nosflare" ,
83- version : "7.9.44 " ,
83+ version : "7.9.45 " ,
8484 icon : "https://raw.githubusercontent.com/Spl0itable/nosflare/main/images/flare.png" ,
8585 // Optional fields (uncomment as needed):
8686 // banner: "https://example.com/banner.jpg",
@@ -2939,42 +2939,50 @@ async function initializeDatabase(db) {
29392939 ` ) . run ( ) ;
29402940 } catch ( _ ) {
29412941 }
2942- const dropIndexes = [
2943- "idx_events_pubkey" ,
2944- "idx_events_kind" ,
2945- "idx_events_created_at_kind" ,
2946- "idx_events_authors_kinds" ,
2947- "idx_events_tag_p_created_at" ,
2948- "idx_events_tag_e_created_at" ,
2949- "idx_events_tag_a_created_at" ,
2950- "idx_events_tag_t_created_at" ,
2951- "idx_events_tag_d_created_at" ,
2952- "idx_events_tag_r_created_at" ,
2953- "idx_events_tag_L_created_at" ,
2954- "idx_events_tag_s_created_at" ,
2955- "idx_events_tag_u_created_at" ,
2956- "idx_events_kind_tag_p" ,
2957- "idx_events_kind_tag_e" ,
2958- "idx_events_kind_tag_a" ,
2959- "idx_events_kind_tag_t" ,
2960- "idx_events_kind_tag_L" ,
2961- "idx_events_kind_tag_s" ,
2962- "idx_events_reply_to" ,
2963- "idx_events_root_thread" ,
2964- "idx_events_kind_created_at_covering" ,
2965- "idx_events_pubkey_kind_created_at_covering" ,
2966- "idx_events_created_at_covering" ,
2967- "idx_events_kind_pubkey_created_at_covering" ,
2968- "idx_tags_name_value" ,
2969- "idx_tags_value" ,
2970- "idx_tags_name_value_event_created"
2971- ] ;
2972- for ( const idx of dropIndexes ) {
2973- await dropSession . prepare ( `DROP INDEX IF EXISTS ${ idx } ` ) . run ( ) ;
2974- }
2975- const dropTables = [ "event_tags_cache" , "mv_follow_graph" , "mv_recent_notes" , "mv_timeline_cache" ] ;
2976- for ( const tbl of dropTables ) {
2977- await dropSession . prepare ( `DROP TABLE IF EXISTS ${ tbl } ` ) . run ( ) ;
2942+ const cleanupDone = await dropSession . prepare (
2943+ "SELECT value FROM system_config WHERE key = 'cleanup_v1' LIMIT 1"
2944+ ) . first ( ) . catch ( ( ) => null ) ;
2945+ if ( ! cleanupDone || cleanupDone . value !== "1" ) {
2946+ const dropIndexes = [
2947+ "idx_events_pubkey" ,
2948+ "idx_events_kind" ,
2949+ "idx_events_created_at_kind" ,
2950+ "idx_events_authors_kinds" ,
2951+ "idx_events_tag_p_created_at" ,
2952+ "idx_events_tag_e_created_at" ,
2953+ "idx_events_tag_a_created_at" ,
2954+ "idx_events_tag_t_created_at" ,
2955+ "idx_events_tag_d_created_at" ,
2956+ "idx_events_tag_r_created_at" ,
2957+ "idx_events_tag_L_created_at" ,
2958+ "idx_events_tag_s_created_at" ,
2959+ "idx_events_tag_u_created_at" ,
2960+ "idx_events_kind_tag_p" ,
2961+ "idx_events_kind_tag_e" ,
2962+ "idx_events_kind_tag_a" ,
2963+ "idx_events_kind_tag_t" ,
2964+ "idx_events_kind_tag_L" ,
2965+ "idx_events_kind_tag_s" ,
2966+ "idx_events_reply_to" ,
2967+ "idx_events_root_thread" ,
2968+ "idx_events_kind_created_at_covering" ,
2969+ "idx_events_pubkey_kind_created_at_covering" ,
2970+ "idx_events_created_at_covering" ,
2971+ "idx_events_kind_pubkey_created_at_covering" ,
2972+ "idx_tags_name_value" ,
2973+ "idx_tags_value" ,
2974+ "idx_tags_name_value_event_created"
2975+ ] ;
2976+ for ( const idx of dropIndexes ) {
2977+ await dropSession . prepare ( `DROP INDEX IF EXISTS ${ idx } ` ) . run ( ) ;
2978+ }
2979+ const dropTables = [ "event_tags_cache" , "mv_follow_graph" , "mv_recent_notes" , "mv_timeline_cache" ] ;
2980+ for ( const tbl of dropTables ) {
2981+ await dropSession . prepare ( `DROP TABLE IF EXISTS ${ tbl } ` ) . run ( ) ;
2982+ }
2983+ await dropSession . prepare (
2984+ "INSERT OR REPLACE INTO system_config (key, value) VALUES ('cleanup_v1', '1')"
2985+ ) . run ( ) ;
29782986 }
29792987 try {
29802988 const initCheck = await dropSession . prepare (
@@ -5087,10 +5095,10 @@ async function getOptimalDO(cf, env, url) {
50875095__name ( getOptimalDO , "getOptimalDO" ) ;
50885096async function getDatabaseSizeBytes ( session ) {
50895097 try {
5090- const pageCountResult = await session . prepare ( "PRAGMA page_count " ) . first ( ) ;
5091- const pageSizeResult = await session . prepare ( "PRAGMA page_size" ) . first ( ) ;
5092- if ( pageCountResult && pageSizeResult ) {
5093- return pageCountResult . page_count * pageSizeResult . page_size ;
5098+ const result = await session . prepare ( "SELECT 1 " ) . run ( ) ;
5099+ const sizeAfter = result . meta ?. size_after ;
5100+ if ( typeof sizeAfter === "number" && sizeAfter > 0 ) {
5101+ return sizeAfter ;
50945102 }
50955103 return 0 ;
50965104 } catch ( error ) {
0 commit comments