From f4f9b69257c50ca894b5a5dccede48e28c82224f Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 16 Apr 2020 22:44:38 +0400 Subject: [PATCH] dk: bug avec la synchro d'un fichier --- dk | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dk b/dk index 4dde61f..43e7a17 100755 --- a/dk +++ b/dk @@ -719,7 +719,6 @@ function build_update_apps() { DEST="${var}_DEST"; DEST="${!DEST}" [ -n "$DEST" ] || DEST="$app/b" - mkdir -p "$DEST" || { eend; return 1; } ORIGIN="${var}_${PROFILE}_ORIGIN"; ORIGIN="${!ORIGIN}" [ -n "$ORIGIN" ] || { ORIGIN="${var}_ORIGIN"; ORIGIN="${!ORIGIN}"; } @@ -733,6 +732,7 @@ function build_update_apps() { TYPE="${var}_TYPE"; TYPE="${!TYPE}" if [ -n "$BUILD_UPDATE_DEVEL" ]; then + mkdir -p "$DEST" || { eend; return 1; } DEST="$DEST/$app" # synchronisation en mode devel @@ -760,6 +760,7 @@ function build_update_apps() { done fi elif [ -n "$URL" ]; then + mkdir -p "$DEST" || { eend; return 1; } DEST="$DEST/$app" if [ -d "$DEST" -a -d "$DEST/.git" ]; then @@ -789,12 +790,20 @@ function build_update_apps() { elif [ -n "$SRC" ]; then if [ -d "$SRC" ]; then local -a rsync_opts; rsync_opts=(-a --delete --exclude .git/ --delete-excluded) - estep "Synchro $SRC/ --> $DEST" - rsync "${rsync_opts[@]}" "$SRC/" "$DEST/" || { eend; return 1; } + SRC="${SRC%/}/" + DEST="${DEST%/}/" + estep "Synchro $SRC --> $DEST" + rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } elif [ -f "$SRC" ]; then local -a rsync_opts; rsync_opts=(-a) - estep "Synchro $SRC --> $DEST" - rsync "${rsync_opts[@]}" "$SRC" "$DEST/" || { eend; return 1; } + if [ "${DEST%/}" != "$DEST" -o -d "$DEST" ]; then + DEST="${DEST%/}/" + estep "Synchro $SRC --> $DEST" + rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } + else + estep "Synchro $SRC --> $DEST" + rsync "${rsync_opts[@]}" "$SRC" "$DEST" || { eend; return 1; } + fi else eerror "$app: $SRC: répertoire/fichier introuvable" eend; return 1