From 89890d4f60452a9fc55d924fd960f4bd72ddbb12 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Tue, 21 Jun 2016 17:46:18 +0100 Subject: [PATCH] Fix move_directory_files tool dependency action when destination is not empty Historically this action moves the contents of the source directory to the destination directory. Commit d38936bd8d9b3612dc0718859067e299651e6c86 broke the install when e.g. the destination is $INSTALL_DIR, which is created by Galaxy and is not empty (contains INSTALLATION.log after first action). --- .../tool_dependencies/recipe/step_handler.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py index ed480293ba7..b12e9d0a673 100755 --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py @@ -847,11 +847,17 @@ class MoveDirectoryFiles( RecipeStep ): def move_directory_files( self, current_dir, source_dir, destination_dir ): source_directory = os.path.abspath( os.path.join( current_dir, source_dir ) ) - destination_directory = os.path.join( destination_dir ) - destination_parent_directory = os.path.dirname(destination_directory) - if not os.path.isdir( destination_parent_directory ): - os.makedirs( destination_parent_directory ) - shutil.move( source_directory, destination_directory ) + destination_directory = os.path.abspath(os.path.join(destination_dir)) + if not os.path.isdir(destination_directory): + os.makedirs(destination_directory) + for dir_entry in os.listdir(source_directory): + source_entry = os.path.join(source_directory, dir_entry) + if os.path.islink(source_entry): + destination_entry = os.path.join(destination_directory, dir_entry) + os.symlink(os.readlink(source_entry), destination_entry) + os.remove(source_entry) + else: + shutil.move(source_entry, destination_directory) def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): #