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