@@ -16,7 +16,6 @@ use crate::common::UfsFactory;
1616use crate :: master:: fs:: policy:: ChooseContext ;
1717use crate :: master:: fs:: MasterFilesystem ;
1818use crate :: master:: { JobContext , JobStore , TaskDetail } ;
19- use curvine_client:: unified:: UfsFileSystem ;
2019use curvine_common:: conf:: ClientConf ;
2120use curvine_common:: error:: FsError ;
2221use curvine_common:: fs:: { FileSystem , Path } ;
@@ -110,18 +109,30 @@ impl LoadJobRunner {
110109 mnt : MountInfo ,
111110 ) -> FsResult < LoadJobResult > {
112111 let source_path = Path :: from_str ( & command. source_path ) ?;
113- let target_path = mnt. get_cv_path ( & source_path) ?;
112+
113+ let target_path = if let Some ( ref target) = command. target_path {
114+ Path :: from_str ( target) ?
115+ } else {
116+ if source_path. is_cv ( ) {
117+ mnt. get_ufs_path ( & source_path) ?
118+ } else {
119+ mnt. get_cv_path ( & source_path) ?
120+ }
121+ } ;
114122
115123 let job_id = Self :: create_job_id ( source_path. full_path ( ) ) ;
116124 let result = LoadJobResult {
117125 job_id : job_id. clone ( ) ,
118126 target_path : target_path. clone_path ( ) ,
119127 } ;
120128
121- let ufs = self . factory . get_ufs ( & mnt) ?;
122- let source_status = ufs. get_status ( & source_path) . await ?;
129+ let source_status = if source_path. is_cv ( ) {
130+ self . master_fs . file_status ( source_path. path ( ) ) ?
131+ } else {
132+ let ufs = self . factory . get_ufs ( & mnt) ?;
133+ ufs. get_status ( & source_path) . await ?
134+ } ;
123135
124- // check job status
125136 if self . check_job_exists ( & job_id, & source_status, & target_path) {
126137 info ! (
127138 "job {}, source_path {} already exists" ,
@@ -136,13 +147,13 @@ impl LoadJobRunner {
136147 & command,
137148 job_id. clone ( ) ,
138149 source_path. clone_uri ( ) ,
139- target_path. clone_path ( ) ,
150+ target_path. clone_uri ( ) ,
140151 & mnt,
141152 & ClientConf :: default ( ) ,
142153 ) ;
143154
144155 let res = self
145- . create_all_tasks ( & mut job_context, source_status, & ufs , & mnt)
156+ . create_all_tasks ( & mut job_context, source_status, & mnt)
146157 . await ;
147158
148159 match res {
@@ -189,7 +200,6 @@ impl LoadJobRunner {
189200 & self ,
190201 job : & mut JobContext ,
191202 source_status : FileStatus ,
192- ufs : & UfsFileSystem ,
193203 mnt : & MountInfo ,
194204 ) -> FsResult < i64 > {
195205 job. update_state ( JobTaskState :: Pending , "Assigning workers" ) ;
@@ -199,18 +209,46 @@ impl LoadJobRunner {
199209 let mut stack = LinkedList :: new ( ) ;
200210 let mut task_index = 0 ;
201211 stack. push_back ( source_status) ;
212+
213+ // Get target base path for direction detection
214+ let target_base = Path :: from_str ( & job. info . target_path ) ?;
215+
202216 while let Some ( status) = stack. pop_front ( ) {
203217 if status. is_dir {
218+ // List directory based on path type
204219 let dir_path = Path :: from_str ( status. path ) ?;
205- let childs = ufs. list_status ( & dir_path) . await ?;
220+ let childs = if dir_path. is_cv ( ) {
221+ // Traverse Curvine directory
222+ self . master_fs . list_status ( dir_path. path ( ) ) ?
223+ } else {
224+ // Traverse UFS directory
225+ let ufs = self . factory . get_ufs ( mnt) ?;
226+ ufs. list_status ( & dir_path) . await ?
227+ } ;
228+
206229 for child in childs {
207230 stack. push_back ( child) ;
208231 }
209232 } else {
210233 let worker = self . choose_worker ( block_size) ?;
211234
212235 let source_path = Path :: from_str ( status. path ) ?;
213- let target_path = mnt. get_cv_path ( & source_path) ?;
236+
237+ // Calculate target_path based on source and target types
238+ let target_path = if source_path. is_cv ( ) && !target_base. is_cv ( ) {
239+ // Export: Curvine → UFS
240+ mnt. get_ufs_path ( & source_path) ?
241+ } else if !source_path. is_cv ( ) && target_base. is_cv ( ) {
242+ // Import: UFS → Curvine
243+ mnt. get_cv_path ( & source_path) ?
244+ } else {
245+ // Same type (Curvine→Curvine or UFS→UFS), not supported yet
246+ return err_box ! (
247+ "Unsupported path combination: source={}, target={}" ,
248+ source_path. full_path( ) ,
249+ target_base. full_path( )
250+ ) ;
251+ } ;
214252
215253 let task_id = format ! ( "{}_task_{}" , job. info. job_id, task_index) ;
216254 task_index += 1 ;
@@ -221,7 +259,7 @@ impl LoadJobRunner {
221259 task_id : task_id. clone ( ) ,
222260 worker : worker. clone ( ) ,
223261 source_path : source_path. clone_uri ( ) ,
224- target_path : target_path. clone_path ( ) ,
262+ target_path : target_path. clone_uri ( ) ,
225263 create_time : LocalTime :: mills ( ) as i64 ,
226264 } ;
227265 job. add_task ( task. clone ( ) ) ;
0 commit comments