File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -29,16 +29,26 @@ echo "Downloading from: $DOWNLOAD_URL"
2929DOWNLOAD_DIR=" ${HOME} /.copilot"
3030mkdir -p " $DOWNLOAD_DIR "
3131
32- # Download and extract
32+ # Download and extract with error handling
33+ TMP_TARBALL=" $( mktemp) "
3334if command -v curl > /dev/null 2>&1 ; then
34- curl -fsSL " $DOWNLOAD_URL " | tar -xz -C " $DOWNLOAD_DIR "
35+ curl -fsSL " $DOWNLOAD_URL " -o " $TMP_TARBALL "
3536elif command -v wget > /dev/null 2>&1 ; then
36- wget -qO- " $DOWNLOAD_URL " | tar -xz -C " $DOWNLOAD_DIR "
37+ wget -qO " $TMP_TARBALL " " $DOWNLOAD_URL "
3738else
38- echo " Error: Neither curl nor wget found. Please install one of them." >&2
39+ echo " Error: Neither curl nor wget found. Please install one of them."
3940 exit 1
4041fi
4142
43+ # Check that the file is a valid tarball
44+ if ! tar -tzf " $TMP_TARBALL " > /dev/null 2>&1 ; then
45+ echo " Error: Downloaded file is not a valid tarball or is corrupted."
46+ rm -f " $TMP_TARBALL "
47+ exit 1
48+ fi
49+
50+ tar -xz -C " $DOWNLOAD_DIR " -f " $TMP_TARBALL "
51+ rm -f " $TMP_TARBALL "
4252if [ " $( id -u 2> /dev/null || echo 1) " -eq 0 ]; then
4353 PREFIX=" ${PREFIX:-/ usr/ local} "
4454else
You can’t perform that action at this time.
0 commit comments