@@ -377,7 +377,15 @@ async fn import_backup_stream_inner<R: tokio::io::AsyncRead + Unpin>(
377377 res = check_backup_version ( context) . await ;
378378 }
379379 if res. is_ok ( ) {
380- res = adjust_bcc_self ( context) . await ;
380+ // All recent backups have `bcc_self` set to "1" before export.
381+ //
382+ // Setting `bcc_self` to "1" on export was introduced on 2024-12-17
383+ // in commit 21664125d798021be75f47d5b0d5006d338b4531
384+ //
385+ // We additionally try to set `bcc_self` to "1" after import here
386+ // for compatibility with older backups,
387+ // but eventually this code can be removed.
388+ res = context. set_config ( Config :: BccSelf , Some ( "1" ) ) . await ;
381389 }
382390 fs:: remove_file ( unpacked_database)
383391 . await
@@ -751,7 +759,7 @@ async fn export_database(
751759 . to_str ( )
752760 . with_context ( || format ! ( "path {} is not valid unicode" , dest. display( ) ) ) ?;
753761
754- adjust_bcc_self ( context) . await ?;
762+ context. set_config ( Config :: BccSelf , Some ( "1" ) ) . await ?;
755763 context
756764 . sql
757765 . set_raw_config_int ( "backup_time" , timestamp)
@@ -785,18 +793,6 @@ async fn export_database(
785793 . await
786794}
787795
788- /// Sets `Config::BccSelf` (and `DeleteServerAfter` to "never" in effect) if needed so that new
789- /// messages are present on the server after a backup restoration or available for all devices in
790- /// multi-device case. NB: Calling this after a backup import isn't reliable as we can crash in
791- /// between, but this is a problem only for old backups, new backups already have `BccSelf` set if
792- /// necessary.
793- async fn adjust_bcc_self ( context : & Context ) -> Result < ( ) > {
794- if context. is_chatmail ( ) . await ? && !context. config_exists ( Config :: BccSelf ) . await ? {
795- context. set_config ( Config :: BccSelf , Some ( "1" ) ) . await ?;
796- }
797- Ok ( ( ) )
798- }
799-
800796async fn check_backup_version ( context : & Context ) -> Result < ( ) > {
801797 let version = ( context. sql . get_raw_config_int ( "backup_version" ) . await ?) . unwrap_or ( 2 ) ;
802798 ensure ! (
0 commit comments