From a3009b46416b5b8fe62be6b417b89b1959ab39fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 25 Mar 2014 03:21:27 +0100 Subject: [PATCH] Fix re-downloading tarball when destination file already exists Previously, curl and wget were instructed to try to resume the download if the destination file already exists. This is supposed to be done via the "Range" HTTP header, but doesn't work well with CloudFront: HTTP server doesn't seem to support byte ranges. Cannot resume. CloudFront is supposed to support ranges, so I don't know what's going on here. It might be failing only in case the existing file is a fully downloaded tarball? In any case, this disables resuming downloads and resorts to simply re-downloading the tarball always, overwriting the existing file. Fixes #487 --- bin/ruby-build | 4 ++-- test/cache.bats | 6 +++--- test/checksum.bats | 10 +++++----- test/mirror.bats | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 17de5168..2800e02a 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -227,7 +227,7 @@ http_head_curl() { } http_get_curl() { - curl -C - -o "${2:--}" -qsSLf "$1" + curl -q -o "${2:--}" -sSLf "$1" } http_head_wget() { @@ -235,7 +235,7 @@ http_head_wget() { } http_get_wget() { - wget -nv -c -O "${2:--}" "$1" + wget -nv -O "${2:--}" "$1" } fetch_tarball() { diff --git a/test/cache.bats b/test/cache.bats index 8c71c358..8819facf 100644 --- a/test/cache.bats +++ b/test/cache.bats @@ -11,7 +11,7 @@ setup() { @test "packages are saved to download cache" { stub md5 true - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum [ "$status" -eq 0 ] @@ -59,7 +59,7 @@ setup() { stub md5 true "echo invalid" "echo $checksum" stub curl "-*I* : true" \ - "-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" + "-q -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" @@ -76,7 +76,7 @@ setup() { @test "nonexistent cache directory is ignored" { stub md5 true - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent" diff --git a/test/checksum.bats b/test/checksum.bats index 3c4ffc3f..dcc8ccda 100644 --- a/test/checksum.bats +++ b/test/checksum.bats @@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL without checksum" { stub md5 true - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum [ "$status" -eq 0 ] @@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL with valid checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum [ "$status" -eq 0 ] @@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL with invalid checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-invalid-checksum [ "$status" -eq 1 ] @@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH= @test "package URL with checksum but no MD5 support" { stub md5 false - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum [ "$status" -eq 0 ] @@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH= @test "package with invalid checksum" { stub md5 true "echo invalid" - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum [ "$status" -eq 1 ] diff --git a/test/mirror.bats b/test/mirror.bats index 9ec45b59..96571de0 100644 --- a/test/mirror.bats +++ b/test/mirror.bats @@ -8,7 +8,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com @test "package URL without checksum bypasses mirror" { stub md5 true - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum echo "$output" >&2 @@ -22,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com @test "package URL with checksum but no MD5 support bypasses mirror" { stub md5 false - stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum [ "$status" -eq 0 ] @@ -39,7 +39,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub md5 true "echo $checksum" stub curl "-*I* $mirror_url : true" \ - "-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" + "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" install_fixture definitions/with-checksum [ "$status" -eq 0 ] @@ -56,7 +56,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub md5 true "echo $checksum" stub curl "-*I* $mirror_url : false" \ - "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum [ "$status" -eq 0 ] @@ -73,8 +73,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub md5 true "echo invalid" "echo $checksum" stub curl "-*I* $mirror_url : true" \ - "-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \ - "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4" + "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ + "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum echo "$output" >&2 @@ -92,7 +92,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com stub md5 true "echo $checksum" stub curl "-*I* : true" \ - "-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \ + "-q -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ install_fixture definitions/with-checksum [ "$status" -eq 0 ]