scripts/fetch in rvm-0.1.44 vs scripts/fetch in rvm-0.1.45
- old
+ new
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
rvm_base_except="selector"
source "$rvm_scripts_path/base"
+result=0
# Set it to cleanup the download on interruption.
trap 'cleanup_download' 1 2 3 15
cleanup_download() {
@@ -59,28 +60,34 @@
else
if [[ ! -z "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "No archive or no MD5, downloading" ; fi
download=1
fi
+# try to convert the ftp url to a http url
+http_url="$(echo $url | sed -e 's/ftp:/http:/' -e 's/git:/http:/')"
+
if [[ $download -gt 0 ]] ; then
rm -f $archive
eval $fetch_command "$url"
result=$?
if [[ $result -gt 0 ]] ; then
retry=0
+ try_http=0
if [[ $result -eq 78 ]] ; then
$rvm_scripts_path/log "error" "The requested url does not exist: '$url'"
+ try_http=1
elif [[ $result -eq 18 ]] ; then
$rvm_scripts_path/log "error" "Partial file. Only a part of the file was transferred. Removing partial and re-trying."
rm -f "$archive"
retry=1
elif [[ $result -eq 33 ]] ; then
if [[ ! -z "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Server does not support 'range' command, removing '$archive'" ; fi
rm -f "$archive"
retry=1
else
- $rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
+ $rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log. Next we'll try to fetch via http."
+ try_http=1
fi
if [[ $retry -eq 1 ]] ; then
eval $fetch_command "$url"
result=$?
@@ -88,10 +95,22 @@
$rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
else
record_md5
fi
fi
+
+ if [[ $try_http -eq 1 ]] ; then
+ eval $fetch_command "$http_url"
+ result=$?
+ if [[ $result -gt 0 ]] ; then
+ $rvm_scripts_path/log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log"
+ else
+ record_md5
+ fi
+ fi
+
else
record_md5
fi
fi
+
exit $result