@@ -777,6 +777,18 @@ pub(crate) async fn sync_task(
777777 let site_path = site_path. clone ( ) ;
778778 let app_state = app_state. clone ( ) ;
779779 let logger_tx = logger_tx. clone ( ) ;
780+
781+ fn send_trim ( site_path : String , dirtylog_cmd_tx : UnboundedSender < DirtyLogCommand > ) {
782+ dirtylog_cmd_tx. unbounded_send ( DirtyLogCommand :: Trim { site : site_path } )
783+ . unwrap_or_else ( |e| {
784+ let err_msg = e. to_string ( ) ;
785+ let DirtyLogCommand :: Trim { site} = e. into_inner ( ) else {
786+ panic ! ( "Logic error" )
787+ } ;
788+ log:: error!( "Cannot send dirtylog Trim command for site {site}: {err_msg}" )
789+ } ) ;
790+ }
791+
780792 match sub_hp {
781793 SubHpInfo :: Normal { sync_path, download_chunk_size } => {
782794 let site_suffix = shvrpc:: util:: strip_prefix_path ( & site_path, & site_info. sub_hp )
@@ -787,7 +799,7 @@ pub(crate) async fn sync_task(
787799 let sync_task = tokio:: spawn ( async move {
788800 let sync_logger = SyncSiteLogger :: new ( & site_path, logger_tx) ;
789801 let sync_result = sync_site_by_download (
790- site_path,
802+ site_path. clone ( ) ,
791803 remote_journal_path,
792804 download_chunk_size,
793805 client_cmd_tx,
@@ -799,6 +811,7 @@ pub(crate) async fn sync_task(
799811 sync_logger. log ( log:: Level :: Error , format ! ( "site sync error: {err}" ) ) ;
800812 }
801813 sync_logger. log ( log:: Level :: Info , "syncing done" ) ;
814+ send_trim ( site_path, app_state. dirtylog_cmd_tx . clone ( ) ) ;
802815 drop ( permit) ;
803816 } ) ;
804817 sync_tasks. push ( sync_task) ;
@@ -810,7 +823,7 @@ pub(crate) async fn sync_task(
810823 let sync_task = tokio:: spawn ( async move {
811824 let sync_logger = SyncSiteLogger :: new ( & site_path, logger_tx) ;
812825 let sync_result = sync_site_legacy (
813- site_path,
826+ site_path. clone ( ) ,
814827 remote_getlog_path,
815828 client_cmd_tx,
816829 & app_state. config . journal_dir ,
@@ -820,6 +833,7 @@ pub(crate) async fn sync_task(
820833 sync_logger. log ( log:: Level :: Error , format ! ( "site sync error: {err}" ) ) ;
821834 }
822835 sync_logger. log ( log:: Level :: Info , "syncing done" ) ;
836+ send_trim ( site_path, app_state. dirtylog_cmd_tx . clone ( ) ) ;
823837 drop ( permit) ;
824838 } ) ;
825839 sync_tasks. push ( sync_task) ;
@@ -831,14 +845,6 @@ pub(crate) async fn sync_task(
831845 }
832846 futures:: future:: join_all ( sync_tasks) . await ;
833847 log:: info!( "Sync logs done in {} s" , sync_start. elapsed( ) . as_secs( ) ) ;
834- sites_to_trim
835- . into_iter ( )
836- . for_each ( |site|
837- app_state. dirtylog_cmd_tx . unbounded_send ( DirtyLogCommand :: Trim { site : site. clone ( ) } )
838- . unwrap_or_else ( |e|
839- log:: error!( "Cannot send dirtylog Trim command for site {site}: {e}" )
840- )
841- ) ;
842848 match cleanup_log_files ( & app_state. config . journal_dir , max_journal_dir_size, days_to_keep) . await {
843849 Ok ( _) => info ! ( "Cleanup journal dir done" ) ,
844850 Err ( err) => error ! ( "Cleanup journal dir error: {err}" ) ,
0 commit comments