1+ use std:: os:: unix:: process:: ExitStatusExt as _;
12use std:: path:: { Path , PathBuf } ;
23
34use tokio:: process:: Command ;
@@ -67,17 +68,28 @@ impl Action for SetTmutilExclusion {
6768
6869 #[ tracing:: instrument( level = "debug" , skip_all) ]
6970 async fn execute ( & mut self ) -> Result < ( ) , ActionError > {
70- execute_command (
71+ let tmutil_ret = execute_command (
7172 Command :: new ( "tmutil" )
7273 . process_group ( 0 )
7374 . arg ( "addexclusion" )
7475 . arg ( & self . path )
7576 . stdin ( std:: process:: Stdio :: null ( ) ) ,
7677 )
77- . await
78- . map_err ( Self :: error) ?;
79-
80- Ok ( ( ) )
78+ . await ;
79+
80+ match tmutil_ret {
81+ Ok ( _) => Ok ( ( ) ) ,
82+ Err ( err) => {
83+ if let crate :: action:: ActionErrorKind :: CommandOutput { ref output, .. } = err {
84+ if output. status . signal ( ) == Some ( 9 ) {
85+ tracing:: debug!( %err, "tmutil failed because it was killed with signal 9; ignoring" ) ;
86+ return Ok ( ( ) ) ;
87+ }
88+ }
89+
90+ Err ( Self :: error ( err) ) ?
91+ } ,
92+ }
8193 }
8294
8395 fn revert_description ( & self ) -> Vec < ActionDescription > {
@@ -86,16 +98,27 @@ impl Action for SetTmutilExclusion {
8698
8799 #[ tracing:: instrument( level = "debug" , skip_all) ]
88100 async fn revert ( & mut self ) -> Result < ( ) , ActionError > {
89- execute_command (
101+ let tmutil_ret = execute_command (
90102 Command :: new ( "tmutil" )
91103 . process_group ( 0 )
92104 . arg ( "removeexclusion" )
93105 . arg ( & self . path )
94106 . stdin ( std:: process:: Stdio :: null ( ) ) ,
95107 )
96- . await
97- . map_err ( Self :: error) ?;
98-
99- Ok ( ( ) )
108+ . await ;
109+
110+ match tmutil_ret {
111+ Ok ( _) => Ok ( ( ) ) ,
112+ Err ( err) => {
113+ if let crate :: action:: ActionErrorKind :: CommandOutput { ref output, .. } = err {
114+ if output. status . signal ( ) == Some ( 9 ) {
115+ tracing:: debug!( %err, "tmutil failed because it was killed with signal 9; ignoring" ) ;
116+ return Ok ( ( ) ) ;
117+ }
118+ }
119+
120+ Err ( Self :: error ( err) ) ?
121+ } ,
122+ }
100123 }
101124}
0 commit comments