@@ -891,50 +891,52 @@ impl RecordingSession {
891891
892892 let combine_tracks_state = merge_tracks ( combine_config, combine_progress_cb) ?;
893893
894- if tmp_output_file. exists ( ) {
895- _ = fs:: rename ( & tmp_output_file, & self . config . output_path ) ;
896- }
894+ if combine_tracks_state == ProgressState :: Finished {
895+ if tmp_output_file. exists ( ) {
896+ _ = fs:: rename ( & tmp_output_file, & self . config . output_path ) ;
897+ }
897898
898- if self . config . output_path . exists ( ) {
899- log:: info!(
900- "Successfully save recorded file: {} " ,
901- self . config. output_path. display( ) ,
902- ) ;
903- } else {
904- if combine_tracks_state == ProgressState :: Finished {
899+ if self . config . output_path . exists ( ) {
900+ log:: info!(
901+ "Successfully save recorded file: {} " ,
902+ self . config. output_path. display( ) ,
903+ ) ;
904+ } else {
905905 return Err ( RecorderError :: Ffmpeg ( format ! (
906906 "Save recorded file: {} failed. Something wrong with ffmpeg operation" ,
907907 self . config. output_path. display( )
908908 ) ) ) ;
909909 }
910- }
911-
912- if self . config . remove_cache_files && self . config . output_path . exists ( ) {
913- if self . config . enable_recording_speaker {
914- _ = fs:: remove_file (
915- self . config
916- . output_path
917- . with_extension ( SPEAKER_AUDIO_EXTENSION ) ,
918- ) ;
919- }
920910
921- if self . config . audio_device_name . is_some ( ) {
922- _ = fs:: remove_file (
923- self . config
924- . output_path
925- . with_extension ( INPUT_AUDIO_EXTENSION ) ,
926- ) ;
911+ if self . config . remove_cache_files && self . config . output_path . exists ( ) {
912+ if self . config . enable_recording_speaker {
913+ _ = fs:: remove_file (
914+ self . config
915+ . output_path
916+ . with_extension ( SPEAKER_AUDIO_EXTENSION ) ,
917+ ) ;
918+ }
927919
928- if self . config . enable_denoise && ! self . config . real_time_denoise {
920+ if self . config . audio_device_name . is_some ( ) {
929921 _ = fs:: remove_file (
930922 self . config
931923 . output_path
932- . with_extension ( INPUT_AUDIO_DENOISE_EXTENSION ) ,
924+ . with_extension ( INPUT_AUDIO_EXTENSION ) ,
933925 ) ;
926+
927+ if self . config . enable_denoise && !self . config . real_time_denoise {
928+ _ = fs:: remove_file (
929+ self . config
930+ . output_path
931+ . with_extension ( INPUT_AUDIO_DENOISE_EXTENSION ) ,
932+ ) ;
933+ }
934934 }
935- }
936935
937- _ = fs:: remove_file ( self . config . output_path . with_extension ( RAW_VIDEO_EXTENSION ) ) ;
936+ _ = fs:: remove_file (
937+ self . config . output_path . with_extension ( RAW_VIDEO_EXTENSION ) ,
938+ ) ;
939+ }
938940 }
939941 }
940942
0 commit comments