Improve conditional logic for directory and file transfer handling

This commit is contained in:
Satyam 2025-02-16 10:44:14 +05:30
parent 7a84e4fb52
commit 86e4dfff89

View File

@ -102,7 +102,7 @@ TEMP_DIR=$(mktemp -d)
# including "." and with the exception of ".git/" # including "." and with the exception of ".git/"
mv "$CLONE_DIR/.git" "$TEMP_DIR/.git" mv "$CLONE_DIR/.git" "$TEMP_DIR/.git"
# check if sourcefile and target file is not set # Do this if sourcefile and target file is not set, means we are doing a directory transfer
if [ -z "$SOURCE_FILE" ] && [ -z "$TARGET_FILE" ] if [ -z "$SOURCE_FILE" ] && [ -z "$TARGET_FILE" ]
then then
# $TARGET_DIRECTORY is '' by default # $TARGET_DIRECTORY is '' by default
@ -123,8 +123,8 @@ ls -al /
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
# if source directory is set # If sourcefile and target file is not set, means we are doing a directory transfer
if [ -n "$SOURCE_DIRECTORY" ] if [ -z "$SOURCE_FILE" ] && [ -z "$TARGET_FILE" ]
then then
echo "[+] List contents of $SOURCE_DIRECTORY" echo "[+] List contents of $SOURCE_DIRECTORY"
ls "$SOURCE_DIRECTORY" ls "$SOURCE_DIRECTORY"
@ -148,6 +148,7 @@ echo "[+] Copying contents of source repository folder $SOURCE_DIRECTORY to fold
cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY" cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY"
fi fi
# If sourcefile and target file is set, means we are doing a file transfer
if [ -n "$SOURCE_FILE" ] && [ -n "$TARGET_FILE" ] if [ -n "$SOURCE_FILE" ] && [ -n "$TARGET_FILE" ]
then then
echo "[+] SOURCE_FILE: $SOURCE_FILE" echo "[+] SOURCE_FILE: $SOURCE_FILE"