From 2ca3439ada6d98690462ef41af0926aea837e3d3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 5 Sep 2018 00:38:19 +0200 Subject: [PATCH] Fix `downloads` directory not being created. --- Library/Homebrew/download_strategy.rb | 3 +-- Library/Homebrew/utils/curl.rb | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 87c1163889..d828e198a5 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -292,6 +292,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy raise CurlDownloadStrategyError, url end ignore_interrupts do + cached_location.dirname.mkpath temporary_path.rename(cached_location) symlink_location.dirname.mkpath end @@ -347,8 +348,6 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy end def _fetch(url:, resolved_url:) - temporary_path.dirname.mkpath - ohai "Downloading from #{resolved_url}" if url != resolved_url if ENV["HOMEBREW_NO_INSECURE_REDIRECT"] && diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 20608b6fc7..2856012bbe 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -47,8 +47,10 @@ def curl(*args) end def curl_download(*args, to: nil, continue_at: "-", **options) - had_incomplete_download ||= File.exist?(to) - curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", to, *args, **options) + destination = Pathname(to) + had_incomplete_download ||= destination.exist? + destination.dirname.mkpath + curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options) rescue ErrorDuringExecution => e # `curl` error 33: HTTP server doesn't seem to support byte ranges. Cannot resume. # HTTP status 416: Requested range not satisfiable