From c3931dd009fc2b352215c64e9ce737e4cb9d6d09 Mon Sep 17 00:00:00 2001 From: Cameron Thompson <50184035+iamromulan@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:24:52 -0400 Subject: [PATCH] Add more diagnostics --- download | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/download b/download index 066d5b3..546fa58 100644 --- a/download +++ b/download @@ -28,6 +28,8 @@ download_file() { output="$2" fi + echo "Downloading file from $1 to $output" + if command -v curl > /dev/null 2>&1; then curl -L -o "$output" "$1" elif command -v wget > /dev/null 2>&1; then @@ -42,12 +44,16 @@ download_github_directory() { # $1: GitHub directory URL (e.g., "https://github.com/iamromulan/quectel-rgmii-toolkit/tree/development/simpleadmin") # $2: Output directory (optional) + echo "Starting download for GitHub directory: $1" + # Extract owner, repo, branch, and directory path from the GitHub URL repo_url=$(echo "$1" | sed -n 's|https://github.com/\([^/]*\)/\([^/]*\)/tree/\([^/]*\)/\(.*\)|\1/\2 \3 \4|p') owner_repo=$(echo "$repo_url" | cut -d' ' -f1) branch=$(echo "$repo_url" | cut -d' ' -f2) directory=$(echo "$repo_url" | cut -d' ' -f3) + echo "Owner/Repo: $owner_repo, Branch: $branch, Directory: $directory" + if [ -z "$owner_repo" ] || [ -z "$branch" ] || [ -z "$directory" ]; then echo -e "\e[1;31mError: Invalid GitHub URL.\e[0m" exit 1 @@ -62,6 +68,8 @@ download_github_directory() { output_dir="$2" fi + echo "Output directory set to: $output_dir" + # Create the output directory if it doesn't exist mkdir -p "$output_dir" @@ -76,6 +84,10 @@ download_github_directory() { exit 1 fi + # Diagnostic: Print the raw contents + echo "API Response Contents:" + echo "$contents" + # Parse and download each file and directory recursively echo "$contents" | grep '"type": "file"' | sed -n 's|.*"path": "\([^"]*\)".*"download_url": "\([^"]*\)".*|"\1" "\2"|p' | while read -r file_path file_url; do echo "File Path: $file_path"