@@ -1382,8 +1382,7 @@ static void me_extract_digest_fields(const Json::Value &digest, char *subject,
13821382}
13831383
13841384static void me_insert_message (xstmt &stm_insert, uint32_t *puidnext,
1385- uint64_t message_id, std::string mid_string, uint32_t message_flags,
1386- uint64_t received_time, uint64_t mod_time) try
1385+ uint64_t message_id, syncmessage_entry e) try
13871386{
13881387 size_t size;
13891388 char from[UADDR_SIZE], rcpt[UADDR_SIZE];
@@ -1392,16 +1391,16 @@ static void me_insert_message(xstmt &stm_insert, uint32_t *puidnext,
13921391
13931392 auto dir = cu_get_maildir ();
13941393 std::string djson;
1395- if (mid_string .size () > 0 ) {
1396- auto ext_path = make_ext_path (dir, mid_string );
1394+ if (e. midstr .size () > 0 ) {
1395+ auto ext_path = make_ext_path (dir, e. midstr );
13971396 size_t slurp_size = 0 ;
13981397 std::unique_ptr<char [], stdlib_delete> slurp_data (HX_slurp_file (ext_path.c_str (), &slurp_size));
13991398 if (slurp_data == nullptr )
1400- mid_string .clear ();
1399+ e. midstr .clear ();
14011400 else
14021401 djson.assign (slurp_data.get (), slurp_size);
14031402 }
1404- if (mid_string .empty ()) {
1403+ if (e. midstr .empty ()) {
14051404 if (!cu_switch_allocator ())
14061405 return ;
14071406 if (!exmdb_client::read_message (dir, nullptr , CP_ACP,
@@ -1432,8 +1431,8 @@ static void me_insert_message(xstmt &stm_insert, uint32_t *puidnext,
14321431 return ;
14331432 digest[" file" ] = " " ;
14341433 djson = json_to_str (digest);
1435- mid_string = std::to_string (time (nullptr )) + " ." + std::to_string (++g_sequence_id) + " .midb" ;
1436- auto ext_path = make_ext_path (dir, mid_string );
1434+ e. midstr = std::to_string (time (nullptr )) + " ." + std::to_string (++g_sequence_id) + " .midb" ;
1435+ auto ext_path = make_ext_path (dir, e. midstr );
14371436 wrapfd fd = open (ext_path.c_str (), O_CREAT | O_TRUNC | O_WRONLY, FMODE_PRIVATE);
14381437 if (fd.get () < 0 ) {
14391438 mlog (LV_ERR, " E-1770: open %s for write: %s" , ext_path.c_str (), strerror (errno));
@@ -1444,7 +1443,7 @@ static void me_insert_message(xstmt &stm_insert, uint32_t *puidnext,
14441443 mlog (LV_ERR, " E-1134: write %s: %s" , ext_path.c_str (), strerror (errno));
14451444 return ;
14461445 }
1447- auto eml_path = make_eml_path (dir, mid_string );
1446+ auto eml_path = make_eml_path (dir, e. midstr );
14481447 fd = open (eml_path.c_str (), O_CREAT | O_TRUNC | O_WRONLY, FMODE_PRIVATE);
14491448 if (fd.get () < 0 ) {
14501449 mlog (LV_ERR, " E-1771: open %s for write: %s" , eml_path.c_str (), strerror (errno));
@@ -1459,8 +1458,8 @@ static void me_insert_message(xstmt &stm_insert, uint32_t *puidnext,
14591458 }
14601459 }
14611460 (*puidnext) ++;
1462- auto b_unsent = !!(message_flags & MSGFLAG_UNSENT) ;
1463- auto b_read = !!(message_flags & MSGFLAG_READ) ;
1461+ bool b_unsent = e. msg_flags & MSGFLAG_UNSENT;
1462+ bool b_read = e. msg_flags & MSGFLAG_READ;
14641463 Json::Value digest;
14651464 if (!json_from_str (djson.c_str (), digest))
14661465 return ;
@@ -1470,16 +1469,16 @@ static void me_insert_message(xstmt &stm_insert, uint32_t *puidnext,
14701469 std::size (rcpt), &size);
14711470 stm_insert.reset ();
14721471 stm_insert.bind_int64 (1 , message_id);
1473- stm_insert.bind_text (2 , mid_string );
1474- stm_insert.bind_int64 (3 , mod_time);
1472+ stm_insert.bind_text (2 , e. midstr . c_str () );
1473+ stm_insert.bind_int64 (3 , e. mod_time );
14751474 stm_insert.bind_int64 (4 , *puidnext);
14761475 stm_insert.bind_int64 (5 , b_unsent);
14771476 stm_insert.bind_int64 (6 , b_read);
14781477 stm_insert.bind_text (7 , subject);
14791478 stm_insert.bind_text (8 , from);
14801479 stm_insert.bind_text (9 , rcpt);
14811480 stm_insert.bind_int64 (10 , size);
1482- stm_insert.bind_int64 (11 , received_time );
1481+ stm_insert.bind_int64 (11 , e. recv_time );
14831482 if (stm_insert.step () != SQLITE_DONE)
14841483 mlog (LV_ERR, " E-2075: sqlite_step not finished" );
14851484} catch (const std::bad_alloc &) {
@@ -1511,8 +1510,7 @@ static void me_sync_message(IDB_ITEM *pidb, xstmt &stm_insert,
15111510 if (gx_sql_exec (pidb->psqlite , sql_string) != SQLITE_OK)
15121511 return ;
15131512 /* e.midstr is known to be empty */
1514- me_insert_message (stm_insert, puidnext, message_id, e.midstr ,
1515- e.msg_flags , e.recv_time , e.mod_time );
1513+ me_insert_message (stm_insert, puidnext, message_id, e);
15161514}
15171515
15181516static BOOL me_sync_contents (IDB_ITEM *pidb, uint64_t folder_id) try
@@ -1596,8 +1594,7 @@ static BOOL me_sync_contents(IDB_ITEM *pidb, uint64_t folder_id) try
15961594 stm_select_msg.bind_int64 (1 , message_id);
15971595 if (stm_select_msg.step () != SQLITE_ROW) {
15981596 me_insert_message (stm_insert_msg, &uidnext, message_id,
1599- entry.midstr .size () > 0 ? entry.midstr .c_str () : nullptr ,
1600- entry.msg_flags , entry.recv_time , entry.mod_time );
1597+ entry);
16011598 } else {
16021599 auto old_mtime = stm_select_msg.col_int64 (2 );
16031600 bool old_unsent = stm_select_msg.col_int64 (3 );
@@ -3567,8 +3564,8 @@ static void notif_msg_added(IDB_ITEM *pidb,
35673564 pstmt = gx_sql_prep (pidb->psqlite , qstr.c_str ());
35683565 if (pstmt == nullptr )
35693566 return ;
3570- me_insert_message (pstmt, &uidnext, message_id, str,
3571- message_flags , received_time, mod_time );
3567+ me_insert_message (pstmt, &uidnext, message_id,
3568+ syncmessage_entry{mod_time , received_time, message_flags, str} );
35723569 pstmt.finalize ();
35733570 if (flags_buff.find (' F' ) != flags_buff.npos ) {
35743571 qstr = fmt::format (" UPDATE messages SET "
0 commit comments