@@ -10,6 +10,7 @@ mod legacy_cache;
1010mod legacy_config;
1111mod timemachine;
1212
13+ use anyhow:: anyhow;
1314use clap:: { Parser , Subcommand } ;
1415use log:: { error, info} ;
1516use std:: { backtrace:: BacktraceStatus , path:: Path } ;
@@ -104,6 +105,8 @@ fn program(cli: Cli, redirect_log_to_console: bool) -> anyhow::Result<()> {
104105 import_legacy_cache_file ( & cli. legacy_cache , & cli. cache ) ?;
105106 match cli. command {
106107 Commands :: Run { dry_run, details } => {
108+ check_for_ongoing_time_machine_backup ( dry_run) ?;
109+
107110 let mut cache = Cache :: open_or_create ( & cli. cache ) ?;
108111 let config = Config :: load_or_create_file ( & cli. config ) ?;
109112
@@ -116,6 +119,8 @@ fn program(cli: Cli, redirect_log_to_console: bool) -> anyhow::Result<()> {
116119 commands:: list:: execute ( & cache, & mut std:: io:: stdout ( ) , separator)
117120 }
118121 Commands :: Reset { dry_run, details } => {
122+ check_for_ongoing_time_machine_backup ( dry_run) ?;
123+
119124 let mut cache = Cache :: open_or_create ( & cli. cache ) ?;
120125
121126 commands:: reset:: execute ( & mut cache, dry_run, details) ;
@@ -145,6 +150,14 @@ fn program(cli: Cli, redirect_log_to_console: bool) -> anyhow::Result<()> {
145150 Ok ( ( ) )
146151}
147152
153+ fn check_for_ongoing_time_machine_backup ( dry_run : bool ) -> anyhow:: Result < ( ) > {
154+ if !dry_run && crate :: timemachine:: is_time_machine_running ( ) {
155+ return Err ( anyhow ! ( "Time Machine is currently doing a backup." ) ) ;
156+ }
157+
158+ Ok ( ( ) )
159+ }
160+
148161fn expand_paths ( cli : & mut Cli ) {
149162 cli. config = shellexpand:: tilde ( & cli. config ) . to_string ( ) ;
150163 cli. cache = shellexpand:: tilde ( & cli. cache ) . to_string ( ) ;
0 commit comments