batch_mode_batch_triple/
move_batch_files.rs1crate::ix!();
3
4impl BatchFileTriple {
5
6 async fn maybe_move_input_to_done(
7 &self,
8 done_dir: impl AsRef<Path>,
9 ) -> Result<(), FileMoveError> {
10
11 if let Some(input_path) = self.input() {
12 let dest = done_dir.as_ref().join(input_path.file_name().unwrap());
13 fs::rename(input_path, dest).await?;
14 info!("moved batch input file to the done directory");
15 }
16 Ok(())
17 }
18
19 async fn maybe_move_output_to_done(
20 &self,
21 done_dir: impl AsRef<Path>,
22 ) -> Result<(), FileMoveError> {
23
24 if let Some(output_path) = self.output() {
25 let dest = done_dir.as_ref().join(output_path.file_name().unwrap());
26 fs::rename(output_path, dest).await?;
27 info!("moved batch output file to the done directory");
28 }
29 Ok(())
30 }
31
32 async fn maybe_move_error_to_done(
33 &self,
34 done_dir: impl AsRef<Path>,
35 ) -> Result<(), FileMoveError> {
36
37 if let Some(error_path) = self.error() {
38 let dest = done_dir.as_ref().join(error_path.file_name().unwrap());
39 fs::rename(error_path, dest).await?;
40 info!("moved batch error file to the done directory");
41 }
42 Ok(())
43 }
44
45 async fn maybe_move_metadata_to_done(
46 &self,
47 done_dir: impl AsRef<Path>,
48 ) -> Result<(), FileMoveError> {
49
50 if let Some(metadata_path) = self.associated_metadata() {
51 let dest = done_dir.as_ref().join(metadata_path.file_name().unwrap());
52 fs::rename(metadata_path, dest).await?;
53 info!("moved batch metadata file to the done directory");
54 }
55 Ok(())
56 }
57
58 pub async fn move_input_and_output_to_done(
59 &self,
60 ) -> Result<(), FileMoveError> {
61
62 let done_dir = self.get_done_directory();
63 self.maybe_move_input_to_done(done_dir).await?;
64 self.maybe_move_output_to_done(done_dir).await?;
65 self.maybe_move_metadata_to_done(done_dir).await?;
66 Ok(())
67 }
68
69 pub async fn move_input_and_error_to_done(
70 &self,
71 ) -> Result<(), FileMoveError> {
72
73 let done_dir = self.get_done_directory();
74 self.maybe_move_input_to_done(done_dir).await?;
75 self.maybe_move_error_to_done(done_dir).await?;
76 self.maybe_move_metadata_to_done(done_dir).await?;
77 Ok(())
78 }
79
80 pub async fn move_all_to_done(
81 &self,
82 ) -> Result<(), FileMoveError> {
83 let done_dir = self.get_done_directory();
84 self.maybe_move_input_to_done(done_dir).await?;
85 self.maybe_move_output_to_done(done_dir).await?;
86 self.maybe_move_error_to_done(done_dir).await?;
87 self.maybe_move_metadata_to_done(done_dir).await?;
88 Ok(())
89 }
90}