From f432498166d30f8b67706456effe2a3c0d340f28 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 25 Nov 2011 16:12:21 +0100 Subject: [PATCH] bug #845 and #995: compare src and dst in mv from ssh tm driver --- src/tm_mad/ssh/tm_mv.sh | 17 +++++++++++------ src/tm_mad/tm_common.sh | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/tm_mad/ssh/tm_mv.sh b/src/tm_mad/ssh/tm_mv.sh index 3f10354e8b..11bb1a5068 100755 --- a/src/tm_mad/ssh/tm_mv.sh +++ b/src/tm_mad/ssh/tm_mv.sh @@ -35,9 +35,14 @@ DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` -log "Moving $SRC_PATH" -exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \ - "Unable to create directory $DST_DIR" -exec_and_log "$SCP -r $SRC $DST" \ - "Could not copy $SRC to $DST" -exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" +if full_src_and_dst_equal; then + log "Not moving $SRC to $DST, they are the same path" +else + log "Moving $SRC_PATH" + exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \ + "Unable to create directory $DST_DIR" + exec_and_log "$SCP -r $SRC $DST" \ + "Could not copy $SRC to $DST" + exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" +fi + diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh index 00ad3fb18a..957027deff 100644 --- a/src/tm_mad/tm_common.sh +++ b/src/tm_mad/tm_common.sh @@ -49,6 +49,20 @@ function fix_dir_slashes dirname "$1/file" | $SED 's/\/+/\//g' } +function get_compare_target +{ + echo "$1" | $SED 's/\/+/\//g' | $SED 's/\\/images$//' +} + +function full_src_and_dst_equal +{ + s=`get_compare_target "$SRC"` + d=`get_compare_target "$DST"` + + [ "$s" == "$d" ] + +} + function fix_var_slashes { ONE_LOCAL_VAR=`fix_dir_slashes "$ONE_LOCAL_VAR"`