@@ -20,7 +20,7 @@ use crate::mimefactory::RECOMMENDED_FILE_SIZE;
2020use crate :: provider:: Provider ;
2121use crate :: sync:: { self , Sync :: * , SyncData } ;
2222use crate :: tools:: get_abs_path;
23- use crate :: transport:: { ConfiguredLoginParam , add_pseudo_transport} ;
23+ use crate :: transport:: { ConfiguredLoginParam , add_pseudo_transport, send_sync_transports } ;
2424use crate :: { constants, stats} ;
2525
2626/// The available configuration keys.
@@ -818,37 +818,39 @@ impl Context {
818818 self . sql
819819 . set_raw_config ( Config :: ConfiguredAddr . as_ref ( ) , Some ( addr) )
820820 . await ?;
821+ } else {
822+ self . sql
823+ . transaction ( |transaction| {
824+ if transaction. query_row (
825+ "SELECT COUNT(*) FROM transports WHERE addr=?" ,
826+ ( addr, ) ,
827+ |row| {
828+ let res: i64 = row. get ( 0 ) ?;
829+ Ok ( res)
830+ } ,
831+ ) ? == 0
832+ {
833+ bail ! ( "Address does not belong to any transport." ) ;
834+ }
835+ transaction. execute (
836+ "UPDATE config SET value=? WHERE keyname='configured_addr'" ,
837+ ( addr, ) ,
838+ ) ?;
839+
840+ // Clean up SMTP and IMAP APPEND queue.
841+ //
842+ // The messages in the queue have a different
843+ // From address so we cannot send them over
844+ // the new SMTP transport.
845+ transaction. execute ( "DELETE FROM smtp" , ( ) ) ?;
846+ transaction. execute ( "DELETE FROM imap_send" , ( ) ) ?;
847+
848+ Ok ( ( ) )
849+ } )
850+ . await ?;
851+ send_sync_transports ( self ) . await ?;
852+ self . sql . uncache_raw_config ( "configured_addr" ) . await ;
821853 }
822- self . sql
823- . transaction ( |transaction| {
824- if transaction. query_row (
825- "SELECT COUNT(*) FROM transports WHERE addr=?" ,
826- ( addr, ) ,
827- |row| {
828- let res: i64 = row. get ( 0 ) ?;
829- Ok ( res)
830- } ,
831- ) ? == 0
832- {
833- bail ! ( "Address does not belong to any transport." ) ;
834- }
835- transaction. execute (
836- "UPDATE config SET value=? WHERE keyname='configured_addr'" ,
837- ( addr, ) ,
838- ) ?;
839-
840- // Clean up SMTP and IMAP APPEND queue.
841- //
842- // The messages in the queue have a different
843- // From address so we cannot send them over
844- // the new SMTP transport.
845- transaction. execute ( "DELETE FROM smtp" , ( ) ) ?;
846- transaction. execute ( "DELETE FROM imap_send" , ( ) ) ?;
847-
848- Ok ( ( ) )
849- } )
850- . await ?;
851- self . sql . uncache_raw_config ( "configured_addr" ) . await ;
852854 }
853855 _ => {
854856 self . sql . set_raw_config ( key. as_ref ( ) , value) . await ?;
0 commit comments