Skip to content

Commit 27e4d10

Browse files
committed
WIP
1 parent bc7816e commit 27e4d10

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

azure-pipelines/end-to-end-tests-dir/asset-caching.ps1

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,26 +188,10 @@ if (-not ($actual -match $expected)) {
188188
}
189189

190190
# ... also with multiple authoritative URLs
191-
if ($IsWindows) {
192-
Refresh-TestRoot
193-
$expected = @(
194-
"^Downloading example3\.html, trying https://nonexistent\.example\.com",
195-
"Trying https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt",
196-
"Successfully downloaded example3\.html",
197-
"$"
198-
) -join "`n"
199-
200-
$actual = Run-VcpkgAndCaptureOutput @commonArgs x-download "$TestDownloadsRoot/example3.html" --sha512 65077997890f66f6041bb3284bb7b88e27631411ccbc253201ca4e00c4bcc58c0d77edffda4975498797cc10772c7fd68fbeb13cc4ac493a3471a9d49e5b6f24 --url https://nonexistent.example.com --url https://raw.githubusercontent.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE.txt
201-
Throw-IfFailed
202-
if (-not ($actual -match $expected)) {
203-
throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed)"
204-
}
205-
}
206-
207-
# Force curl with --header
208191
Refresh-TestRoot
209192
$expected = @(
210193
"^Downloading example3\.html, trying https://nonexistent\.example\.com",
194+
"error: curl operation failed with error code 6 \(Couldn't resolve host name\)\. This is a non-transient error, won't retry downloading from https://nonexistent\.example\.com",
211195
"Trying https://raw\.githubusercontent\.com/microsoft/vcpkg-tool/1767aaee7b229c609f7ad5cf2f57b6a6cc309fb8/LICENSE\.txt"
212196
"Successfully downloaded example3\.html",
213197
"$"

include/vcpkg/base/curl.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
#pragma once
12

2-
#ifdef _MSC_VER
3-
#pragma warning(push) // Save current warning state
4-
#pragma warning(disable : 6101) // Disable specific warning (e.g., warning 4996)
5-
#endif
3+
#include <vcpkg/base/pragmas.h>
64

5+
VCPKG_MSVC_WARNING(push)
6+
// note: disable warning triggered by curl headers
7+
// ws2tcpip.h(968): warning C6101: Returning uninitialized memory '*Mtu': A successful path through the function does not set the named _Out_ parameter.
8+
VCPKG_MSVC_WARNING(disable: 6101)
79
#include <curl/curl.h>
810
#include <curl/multi.h>
9-
10-
#ifdef _MSC_VER
11-
#pragma warning(pop)
12-
#endif
11+
VCPKG_MSVC_WARNING(pop)
1312

1413
namespace vcpkg
1514
{

include/vcpkg/base/message-data.inc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,10 @@ DECLARE_MESSAGE(CurlFailedGeneric,
967967
(msg::exit_code, msg::error_msg),
968968
"curl is the name of a program, see curl.se.",
969969
"curl operation failed with error code {exit_code} ({error_msg}).")
970+
DECLARE_MESSAGE(CurlFailedGenericNoRetryAddendum,
971+
(msg::url),
972+
"curl is the name of a program, see curl.se.",
973+
"This is a non-transient error, won't retry downloading from {url}.")
970974
DECLARE_MESSAGE(CurlFailedGenericWithRetry,
971975
(msg::exit_code, msg::error_msg, msg::count, msg::value),
972976
"curl is the name of a program, see curl.se. {value} is the maximum amount of retries.",

locales/messages.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@
563563
"_CreationFailed.comment": "An example of {path} is /foo/bar.",
564564
"CurlFailedGeneric": "curl operation failed with error code {exit_code} ({error_msg}).",
565565
"_CurlFailedGeneric.comment": "curl is the name of a program, see curl.se. An example of {exit_code} is 127. An example of {error_msg} is File Not Found.",
566+
"CurlFailedGenericNoRetryAddendum": "This is a non-transient error, won't retry downloading from {url}.",
567+
"_CurlFailedGenericNoRetryAddendum.comment": "curl is the name of a program, see curl.se. An example of {url} is https://github.com/microsoft/vcpkg.",
566568
"CurlFailedGenericWithRetry": "curl operation failed with error code {exit_code} ({error_msg}) retry {count} of {value}.",
567569
"_CurlFailedGenericWithRetry.comment": "curl is the name of a program, see curl.se. {value} is the maximum amount of retries. An example of {exit_code} is 127. An example of {error_msg} is File Not Found. An example of {count} is 42.",
568570
"CurlFailedHttpResponse": "curl operation failed with HTTP response code {exit_code}.",

src/vcpkg/base/downloads.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,11 @@ namespace vcpkg
621621
}
622622
else
623623
{
624-
context.report_error(msg::format(msgCurlFailedGeneric,
625-
msg::exit_code = static_cast<int>(curl_code),
626-
msg::error_msg = curl_easy_strerror(curl_code)));
624+
context.report_error(
625+
msg::format(msgCurlFailedGeneric,
626+
msg::exit_code = static_cast<int>(curl_code),
627+
msg::error_msg = curl_easy_strerror(curl_code))
628+
.append(msg::format(msgCurlFailedGenericNoRetryAddendum, msg::url = sanitized_url)));
627629
}
628630
}
629631
} while (should_retry && retries_count < retry_delay.size());
@@ -1126,6 +1128,11 @@ namespace vcpkg
11261128
context, download_path, display_path, asset_cache_settings, maybe_sha512);
11271129
return true;
11281130
}
1131+
else
1132+
{
1133+
asset_cache_attempt_context.commit();
1134+
authoritative_attempt_context.commit();
1135+
}
11291136

11301137
while (++first_sanitized_url, ++first_raw_url != last_raw_url)
11311138
{

0 commit comments

Comments
 (0)