Skip to content

Commit

Permalink
Feature: cache md5 sums on successful download.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Feb 3, 2010
1 parent decec08 commit 0b3fb69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions scripts/fetch
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi

trap "if [[ -d $rvm_tmp_path/ ]] && [[ -f $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15

record_md5() {
if [[ "Darwin" = "$(uname)" ]] ; then
archive_md5="$(md5 $archive | awk '{print $NF}')"
else
archive_md5="$(md5sum $archive | awk '{print $1}')"
fi
$rvm_scripts_path/db "$rvm_config_path/md5" "$archive" "$archive_md5"
}

if ! which curl &> /dev/null; then
$rvm_scripts_path/log "fail" "rvm requires curl, which does not seem to exist in your path :("
exit 1
else
fetch_command="curl -O -L --create-dirs -C - " # -s for silent
fi

pushd "$rvm_archives_path" > /dev/null 2>&1
builtin cd "$rvm_archives_path"

if [[ -z "$1" ]] ; then $rvm_scripts_path/log "fail" "BUG: $0 called without an argument :/" ; exit 1 ; fi

Expand Down Expand Up @@ -60,11 +69,13 @@ if [[ $download -gt 0 ]] ; then
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
popd > /dev/null 2>&1
fi

exit $result
1 change: 0 additions & 1 deletion scripts/manage
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ __rvm_install_ruby() {
result=$? ; if [[ "$result" -gt 0 ]] ; then
$rvm_scripts_path/log "error" "There has been an error while trying to fetch the source. Aborting the installation." ; __rvm_pushpop ; return $result
fi

mv "$rvm_archives_path/macruby_nightly-latest.pkg" "$rvm_archives_path/macruby_nightly.pkg"
__rvm_run "macruby/extract" "sudo installer -pkg '$rvm_archives_path/macruby_nightly.pkg' -target '/'"
mkdir -p "$rvm_ruby_home/bin"
Expand Down
1 change: 1 addition & 0 deletions scripts/utility
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ __rvm_gems_select() {
rvm_ruby_gem_path="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"

# Global gems cache
mkdir -p "$rvm_ruby_gem_home"
if [[ ! -L "$rvm_ruby_gem_home/cache" ]] ; then
mv "$rvm_ruby_gem_home/cache"/* "$rvm_gem_path/cache/"
rm -rf "$rvm_ruby_gem_home/cache"
Expand Down

0 comments on commit 0b3fb69

Please sign in to comment.