From 52ec4b0e83079b1493439ac6af95cbda39d7f418 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 17 Feb 2026 17:37:46 -0500 Subject: [PATCH 1/3] nom-cp: create remote directories before copying files Ensures destination directories exist before writing files, for both the rsync (VSCode sync-rsync) and nomad alloc exec code paths. Co-Authored-By: Claude Opus 4.6 --- aliases | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/aliases b/aliases index 31dd76b..71014ef 100644 --- a/aliases +++ b/aliases @@ -119,7 +119,18 @@ function nom-cp() { [ $MAIN ] && RSYNC=true [ ! $MAIN ] && [ "$RSYNC_BRANCHES" ] && RSYNC=true - [ $RSYNC ] && { set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e; } + echo "$@" + + if [ $RSYNC ]; then + # Create remote directory if needed + local RSYNC_DEST="${@: -1}" + if [[ "$RSYNC_DEST" == *:* ]]; then + local RSYNC_HOST="${RSYNC_DEST%%:*}" + local RSYNC_DIR="$(dirname "${RSYNC_DEST#*:}")" + ssh "$RSYNC_HOST" "mkdir -p '$RSYNC_DIR'" + fi + set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e + fi # this is a special exception project where we DONT want to ALSO copy file to nomad deploy [ $MAIN ] && [ "$JOB" = "ia-petabox" ] && [ ! $NOM_CP_PETABOX_MAIN ] && exit 0 @@ -132,6 +143,10 @@ function nom-cp() { return fi + # Create remote directory if needed + local REST_DIR=$(dirname "$REST") + [ "$REST_DIR" != "." ] && nomad alloc exec -task $TASK "$ALLOC" sh -c "mkdir -p '$REST_DIR'" + # HinD updated nomad clusters w/ latest nomad seem to *not* get the stdin close properly # (and thus hang). So timeout/kill after 2s :( tracey 2024/3 ) set +e From a2702f7e139b5fa0ee00b4fb86758769fd8d651e Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 18 Feb 2026 12:34:41 -0500 Subject: [PATCH 2/3] Add explainer comments --- aliases | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aliases b/aliases index 71014ef..92273f7 100644 --- a/aliases +++ b/aliases @@ -122,11 +122,12 @@ function nom-cp() { echo "$@" if [ $RSYNC ]; then - # Create remote directory if needed + # Parse host:path from rsync destination and mkdir -p via ssh, + # since rsync won't create intermediate directories on its own. local RSYNC_DEST="${@: -1}" if [[ "$RSYNC_DEST" == *:* ]]; then - local RSYNC_HOST="${RSYNC_DEST%%:*}" - local RSYNC_DIR="$(dirname "${RSYNC_DEST#*:}")" + local RSYNC_HOST="${RSYNC_DEST%%:*}" # strip longest match of :* from end + local RSYNC_DIR="$(dirname "${RSYNC_DEST#*:}")" # strip shortest match of *: from start ssh "$RSYNC_HOST" "mkdir -p '$RSYNC_DIR'" fi set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e @@ -143,7 +144,7 @@ function nom-cp() { return fi - # Create remote directory if needed + # Create destination directory inside the container before piping the file in, local REST_DIR=$(dirname "$REST") [ "$REST_DIR" != "." ] && nomad alloc exec -task $TASK "$ALLOC" sh -c "mkdir -p '$REST_DIR'" From 4c20820452a1477918a57927249b891ef72294a9 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 18 Feb 2026 12:35:53 -0500 Subject: [PATCH 3/3] Fix typo --- aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases b/aliases index 92273f7..a2b783e 100644 --- a/aliases +++ b/aliases @@ -144,7 +144,7 @@ function nom-cp() { return fi - # Create destination directory inside the container before piping the file in, + # Create destination directory inside the container before piping the file in local REST_DIR=$(dirname "$REST") [ "$REST_DIR" != "." ] && nomad alloc exec -task $TASK "$ALLOC" sh -c "mkdir -p '$REST_DIR'"