@@ -5,7 +5,6 @@ use crate::{
55} ;
66use cwl:: {
77 inputs:: CommandInputParameter ,
8- outputs:: CommandOutputParameter ,
98 requirements:: { Requirement , WorkDirItem } ,
109 types:: { CWLType , DefaultValue , Directory , Entry , File , PathItem } ,
1110 CWLDocument ,
@@ -48,34 +47,6 @@ pub(crate) fn stage_required_files<P: AsRef<Path>, Q: AsRef<Path>, R: AsRef<Path
4847 Ok ( staged_files)
4948}
5049
51- pub ( crate ) fn unstage_files ( staged_files : & [ String ] , tmp_dir : & Path , outputs : & [ CommandOutputParameter ] ) -> Result < ( ) , Box < dyn Error > > {
52- for file in staged_files {
53- let mut should_remove = true ;
54-
55- for output in outputs {
56- if let Some ( binding) = & output. output_binding {
57- if let Some ( glob) = & binding. glob {
58- let binding_path = tmp_dir. join ( glob) ;
59- if binding_path. to_str ( ) . unwrap ( ) . matches ( file) . next ( ) . is_some ( ) {
60- should_remove = false ;
61- break ;
62- }
63- }
64- }
65- }
66-
67- if should_remove {
68- let path = Path :: new ( file) ;
69- if path. is_dir ( ) {
70- fs:: remove_dir_all ( file) . map_err ( |e| format ! ( "Could not remove staged dir {}: {}" , file, e) ) ?;
71- } else {
72- fs:: remove_file ( file) . map_err ( |e| format ! ( "Could not remove staged file {}: {}" , file, e) ) ?;
73- }
74- }
75- }
76- Ok ( ( ) )
77- }
78-
7950fn stage_requirements ( requirements : & [ Requirement ] , tool_path : & Path , path : & Path ) -> Result < Vec < String > , Box < dyn Error > > {
8051 let mut staged_files = vec ! [ ] ;
8152
@@ -321,7 +292,6 @@ fn handle_filename(value: &DefaultValue) -> String {
321292mod tests {
322293 use super :: * ;
323294 use cwl:: {
324- outputs:: CommandOutputBinding ,
325295 requirements:: InitialWorkDirRequirement ,
326296 types:: { Directory , File } ,
327297 StringOrNumber ,
@@ -419,83 +389,6 @@ mod tests {
419389 assert_eq ! ( list[ 0 ] , expected_path. to_string_lossy( ) . into_owned( ) ) ;
420390 }
421391
422- #[ test]
423- #[ serial]
424- fn test_unstage_files ( ) {
425- let tmp_dir = tempdir ( ) . unwrap ( ) ;
426-
427- let test_dir = "tests/test_data/input.txt" ;
428-
429- let input = CommandInputParameter :: default ( ) . with_id ( "test" ) . with_type ( CWLType :: File ) ;
430- let value = DefaultValue :: File ( File :: from_location ( test_dir) ) ;
431-
432- let list = stage_input_files (
433- & [ input] ,
434- & mut RuntimeEnvironment :: default ( ) . with_inputs ( HashMap :: from ( [ ( "test" . to_string ( ) , value) ] ) ) ,
435- Path :: new ( "../../" ) ,
436- tmp_dir. path ( ) ,
437- & PathBuf :: from ( "" ) ,
438- )
439- . unwrap ( ) ;
440-
441- unstage_files ( & list, tmp_dir. path ( ) , & [ ] ) . unwrap ( ) ;
442- //file should be gone
443- assert ! ( !Path :: new( & list[ 0 ] ) . exists( ) ) ;
444- }
445-
446- #[ test]
447- #[ serial]
448- fn test_unstage_files_dir ( ) {
449- let tmp_dir = tempdir ( ) . unwrap ( ) ;
450-
451- let test_dir = "tests/test_data" ;
452-
453- let input = CommandInputParameter :: default ( ) . with_id ( "test" ) . with_type ( CWLType :: Directory ) ;
454- let value = DefaultValue :: Directory ( Directory :: from_location ( test_dir) ) ;
455-
456- let list = stage_input_files (
457- & [ input] ,
458- & mut RuntimeEnvironment :: default ( ) . with_inputs ( HashMap :: from ( [ ( "test" . to_string ( ) , value) ] ) ) ,
459- Path :: new ( "../../" ) ,
460- tmp_dir. path ( ) ,
461- & PathBuf :: from ( "" ) ,
462- )
463- . unwrap ( ) ;
464-
465- unstage_files ( & list, tmp_dir. path ( ) , & [ ] ) . unwrap ( ) ;
466- //file should be gone
467- assert ! ( !Path :: new( & list[ 0 ] ) . exists( ) ) ;
468- }
469-
470- #[ test]
471- #[ serial]
472- fn test_unstage_files_not_in_output ( ) {
473- let tmp_dir = tempdir ( ) . unwrap ( ) ;
474-
475- let test_file = "tests/test_data/input.txt" ;
476-
477- let input = CommandInputParameter :: default ( ) . with_id ( "test" ) . with_type ( CWLType :: File ) ;
478- let value = DefaultValue :: File ( File :: from_location ( test_file) ) ;
479-
480- let output = CommandOutputParameter :: default ( ) . with_binding ( CommandOutputBinding {
481- glob : Some ( "tests/test_data/input.txt" . to_string ( ) ) ,
482- ..Default :: default ( )
483- } ) ;
484-
485- let list = stage_input_files (
486- & [ input] ,
487- & mut RuntimeEnvironment :: default ( ) . with_inputs ( HashMap :: from ( [ ( "test" . to_string ( ) , value) ] ) ) ,
488- Path :: new ( "../../" ) ,
489- tmp_dir. path ( ) ,
490- & PathBuf :: from ( "" ) ,
491- )
492- . unwrap ( ) ;
493-
494- unstage_files ( & list, tmp_dir. path ( ) , & [ output] ) . unwrap ( ) ;
495- //file should still be there
496- assert ! ( Path :: new( & list[ 0 ] ) . exists( ) ) ;
497- }
498-
499392 #[ test]
500393 #[ serial]
501394 fn test_stage_secondary_files ( ) {
0 commit comments