5
5
#include < vcpkg/base/json.h>
6
6
#include < vcpkg/base/message_sinks.h>
7
7
#include < vcpkg/base/parse.h>
8
+ #include < vcpkg/base/strings.h>
8
9
#include < vcpkg/base/system.debug.h>
9
10
#include < vcpkg/base/system.h>
10
11
#include < vcpkg/base/system.process.h>
@@ -334,18 +335,6 @@ namespace vcpkg
334
335
{
335
336
std::string actual_hash =
336
337
vcpkg::Hash::get_file_hash (fs, downloaded_path, Hash::Algorithm::Sha512).value_or_exit (VCPKG_LINE_INFO);
337
-
338
- // <HACK to handle NuGet.org changing nupkg hashes.>
339
- // This is the NEW hash for 7zip
340
- if (actual_hash == " a9dfaaafd15d98a2ac83682867ec5766720acf6e99d40d1a00d480692752603bf3f3742623f0ea85647a92374df"
341
- " 405f331afd6021c5cf36af43ee8db198129c0" )
342
- {
343
- // This is the OLD hash for 7zip
344
- actual_hash = " 8c75314102e68d2b2347d592f8e3eb05812e1ebb525decbac472231633753f1d4ca31c8e6881a36144a8da26b257"
345
- " 1305b3ae3f4e2b85fc4a290aeda63d1a13b8" ;
346
- }
347
- // </HACK>
348
-
349
338
if (!Strings::case_insensitive_ascii_equals (sha512, actual_hash))
350
339
{
351
340
return msg::format_error (msgDownloadFailedHashMismatch,
@@ -366,22 +355,18 @@ namespace vcpkg
366
355
try_verify_downloaded_file_hash (fs, url, downloaded_path, sha512).value_or_exit (VCPKG_LINE_INFO);
367
356
}
368
357
369
- static bool check_downloaded_file_hash (Filesystem& fs,
370
- const Optional<std::string>& hash,
371
- StringView sanitized_url,
372
- const Path& download_part_path,
373
- std::vector<LocalizedString>& errors)
358
+ static ExpectedL<Unit> check_downloaded_file_hash (Filesystem& fs,
359
+ const Optional<std::string>& hash,
360
+ StringView sanitized_url,
361
+ const Path& download_part_path)
374
362
{
375
363
if (auto p = hash.get ())
376
364
{
377
- auto maybe_success = try_verify_downloaded_file_hash (fs, sanitized_url, download_part_path, *p);
378
- if (!maybe_success.has_value ())
379
- {
380
- errors.push_back (std::move (maybe_success).error ());
381
- return false ;
382
- }
365
+ return try_verify_downloaded_file_hash (fs, sanitized_url, download_part_path, *p);
383
366
}
384
- return true ;
367
+
368
+ Debug::println (" Skipping hash check because none was specified." );
369
+ return Unit{};
385
370
}
386
371
387
372
static void url_heads_inner (View<std::string> urls,
@@ -444,7 +429,11 @@ namespace vcpkg
444
429
{
445
430
url_heads_inner ({urls.data () + i, batch_size}, headers, &ret, secrets);
446
431
}
447
- if (i != urls.size ()) url_heads_inner ({urls.begin () + i, urls.end ()}, headers, &ret, secrets);
432
+
433
+ if (i != urls.size ())
434
+ {
435
+ url_heads_inner ({urls.begin () + i, urls.end ()}, headers, &ret, secrets);
436
+ }
448
437
449
438
return ret;
450
439
}
@@ -513,7 +502,11 @@ namespace vcpkg
513
502
{
514
503
download_files_inner (fs, {url_pairs.data () + i, batch_size}, headers, &ret);
515
504
}
516
- if (i != url_pairs.size ()) download_files_inner (fs, {url_pairs.begin () + i, url_pairs.end ()}, headers, &ret);
505
+
506
+ if (i != url_pairs.size ())
507
+ {
508
+ download_files_inner (fs, {url_pairs.begin () + i, url_pairs.end ()}, headers, &ret);
509
+ }
517
510
518
511
Checks::msg_check_exit (VCPKG_LINE_INFO,
519
512
ret.size () == url_pairs.size (),
@@ -561,6 +554,7 @@ namespace vcpkg
561
554
{
562
555
cmd.string_arg (" -H" ).string_arg (header);
563
556
}
557
+
564
558
cmd.string_arg (" -w" ).string_arg (" \\ n" + guid_marker.to_string () + " %{http_code}" );
565
559
cmd.string_arg (url);
566
560
cmd.string_arg (" -T" ).string_arg (file);
@@ -733,11 +727,16 @@ namespace vcpkg
733
727
{
734
728
if (download_winhttp (fs, download_path_part_path, split_uri, url, secrets, errors, progress_sink))
735
729
{
736
- if (check_downloaded_file_hash (fs, sha512, url, download_path_part_path, errors))
730
+ auto maybe_hash_check = check_downloaded_file_hash (fs, sha512, url, download_path_part_path);
731
+ if (maybe_hash_check.has_value ())
737
732
{
738
733
fs.rename (download_path_part_path, download_path, VCPKG_LINE_INFO);
739
734
return true ;
740
735
}
736
+ else
737
+ {
738
+ errors.push_back (std::move (maybe_hash_check).error ());
739
+ }
741
740
}
742
741
return false ;
743
742
}
@@ -758,7 +757,7 @@ namespace vcpkg
758
757
}
759
758
760
759
std::string non_progress_lines;
761
- const auto maybe_exit_code = cmd_execute_and_stream_lines (
760
+ auto maybe_exit_code = cmd_execute_and_stream_lines (
762
761
cmd,
763
762
[&](StringView line) {
764
763
const auto maybe_parsed = try_parse_curl_progress_data (line);
@@ -782,15 +781,22 @@ namespace vcpkg
782
781
if (*exit_code != 0 )
783
782
{
784
783
errors.push_back (
785
- msg::format_error (msgDownloadFailedCurl, msg::url = sanitized_url, msg::exit_code = *exit_code));
784
+ msg::format_error (msgDownloadFailedCurl, msg::url = sanitized_url, msg::exit_code = *exit_code)
785
+ .append_raw (' \n ' )
786
+ .append_raw (Strings::join (" \n " , non_progress_lines)));
786
787
return false ;
787
788
}
788
789
789
- if (check_downloaded_file_hash (fs, sha512, sanitized_url, download_path_part_path, errors))
790
+ auto maybe_hash_check = check_downloaded_file_hash (fs, sha512, sanitized_url, download_path_part_path);
791
+ if (maybe_hash_check.has_value ())
790
792
{
791
793
fs.rename (download_path_part_path, download_path, VCPKG_LINE_INFO);
792
794
return true ;
793
795
}
796
+ else
797
+ {
798
+ errors.push_back (std::move (maybe_hash_check).error ());
799
+ }
794
800
}
795
801
else
796
802
{
0 commit comments