@@ -75,6 +75,10 @@ impl OARState {
7575 OARState :: UnknownState => "UnknownState" ,
7676 }
7777 }
78+
79+ fn is_terminal ( & self ) -> bool {
80+ self == & OARState :: Terminated || self == & OARState :: Failed || self == & OARState :: UnknownState
81+ }
7882}
7983
8084impl TryFrom < & str > for OARState {
@@ -144,7 +148,7 @@ impl Job {
144148 }
145149
146150 fn finished ( & self ) -> bool {
147- self . state == OARState :: Terminated || self . state == OARState :: Failed
151+ self . state . is_terminal ( )
148152 }
149153
150154 pub async fn submit_job ( & mut self ) -> JobResult {
@@ -207,13 +211,16 @@ impl Job {
207211 }
208212
209213 pub async fn job_terminated ( & mut self ) -> JobResult {
210- rsync_results (
214+ if let Err ( rsync_result ) = rsync_results (
211215 & self . site ,
212216 self . node . cluster . as_deref ( ) . unwrap ( ) ,
213217 & self . node . uid ,
214- ) ?;
218+ ) {
219+ self . state = OARState :: UnknownState ;
220+ }
215221 Ok ( ( ) )
216222 }
223+
217224}
218225
219226#[ derive( Debug , Serialize , Deserialize , Clone ) ]
@@ -388,6 +395,7 @@ pub fn rsync_results(site: &str, cluster: &str, node: &str) -> JobResult {
388395 debug ! ( "Rsync with site {} done.\n {:?}" , site, out) ;
389396 } else {
390397 debug ! ( "Rsync with site {} failed.\n {:?} ; {:?}" , site, out, err) ;
398+ return Err ( JobError :: UnknownState ( "Rsync failed" . to_string ( ) ) )
391399 }
392400 } else {
393401 p. terminate ( ) ?;
@@ -408,6 +416,7 @@ pub fn rsync_results(site: &str, cluster: &str, node: &str) -> JobResult {
408416 debug ! ( "Checksum success.\n {:?}" , out) ;
409417 } else {
410418 debug ! ( "Checksum fail.\n {:?} ; {:?}" , out, err) ;
419+ return Err ( JobError :: UnknownState ( "Checksum failed" . to_string ( ) ) )
411420 }
412421 } else {
413422 p. terminate ( ) ?;
0 commit comments