diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index b0f7757f..09f8e018 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -63,16 +63,22 @@ case "$state_should" in set_attributes=1 if [ "$type" = "directory" ]; then # our destination is currently a directory, move it out of the way, - # then delete it after moving our upload into place cat << DONE destination_old="\$(mktemp "${destination}.cdist.XXXXXXXXXX")" -mv "$destination" "$destination_old" -mv "$destination_upload" "$destination" -rm -rf "$destination_old" +mv "$destination" "\$destination_old" +DONE + fi + + # move our upload into place + cat << DONE +mv "$destination_upload" "$destination" +DONE + + if [ "$type" = "directory" ]; then + # delete the legacy directory + cat << DONE +rm -rf "\$destination_old" DONE - else - # move our upload into place - echo "mv \"$destination_upload\" \"$destination\"" fi fi