33#include < vcpkg/base/parse.h>
44#include < vcpkg/base/system.debug.h>
55#include < vcpkg/base/system.print.h>
6+ #include < vcpkg/base/util.h>
67
8+ #include < vcpkg/binarycaching.h>
79#include < vcpkg/commands.xdownload.h>
810#include < vcpkg/vcpkgcmdarguments.h>
9- #include < vcpkg/vcpkgpaths.h>
1011
1112namespace vcpkg ::Commands::X_Download
1213{
@@ -38,11 +39,11 @@ namespace vcpkg::Commands::X_Download
3839 }
3940 static bool is_lower_sha512 (StringView sha) { return sha.size () == 128 && is_lower_hex (sha); }
4041
41- void perform_and_exit (const VcpkgCmdArguments& args, const VcpkgPaths& paths )
42+ void perform_and_exit (const VcpkgCmdArguments& args, Files::Filesystem& fs )
4243 {
4344 auto parsed = args.parse_arguments (COMMAND_STRUCTURE);
44- fs::path file = Files::combine (paths. original_cwd , fs::u8path ( args.command_arguments [ 0 ]) );
45- file. make_preferred ( );
45+ auto download_manager = create_download_manager ( args.asset_sources_template ). value_or_exit (VCPKG_LINE_INFO );
46+ fs::path file = fs. absolute (VCPKG_LINE_INFO, fs::u8path (args. command_arguments [ 0 ]) );
4647
4748 std::string sha = Strings::ascii_to_lowercase (std::string (args.command_arguments [1 ]));
4849 if (!is_lower_sha512 (sha))
@@ -51,8 +52,6 @@ namespace vcpkg::Commands::X_Download
5152 VCPKG_LINE_INFO, " Error: SHA512's must be 128 hex characters: '%s'" , args.command_arguments [1 ]);
5253 }
5354
54- auto & fs = paths.get_filesystem ();
55-
5655 // Is this a store command?
5756 if (Util::Sets::contains (parsed.switches , OPTION_STORE))
5857 {
@@ -65,7 +64,7 @@ namespace vcpkg::Commands::X_Download
6564 auto hash =
6665 Strings::ascii_to_lowercase (Hash::get_file_hash (VCPKG_LINE_INFO, fs, file, Hash::Algorithm::Sha512));
6766 if (hash != sha) Checks::exit_with_message (VCPKG_LINE_INFO, " Error: file to store does not match hash" );
68- paths. get_download_manager () .put_file_to_mirror (fs, file, sha).value_or_exit (VCPKG_LINE_INFO);
67+ download_manager .put_file_to_mirror (fs, file, sha).value_or_exit (VCPKG_LINE_INFO);
6968 Checks::exit_success (VCPKG_LINE_INFO);
7069 }
7170 else
@@ -81,18 +80,18 @@ namespace vcpkg::Commands::X_Download
8180 auto it_urls = parsed.multisettings .find (OPTION_URL);
8281 if (it_urls == parsed.multisettings .end ())
8382 {
84- paths. get_download_manager () .download_file (fs, View<std::string>{}, headers, file, sha);
83+ download_manager .download_file (fs, View<std::string>{}, headers, file, sha);
8584 }
8685 else
8786 {
88- paths. get_download_manager () .download_file (fs, it_urls->second , headers, file, sha);
87+ download_manager .download_file (fs, it_urls->second , headers, file, sha);
8988 }
9089 Checks::exit_success (VCPKG_LINE_INFO);
9190 }
9291 }
9392
94- void XDownloadCommand::perform_and_exit (const VcpkgCmdArguments& args, const VcpkgPaths& paths ) const
93+ void XDownloadCommand::perform_and_exit (const VcpkgCmdArguments& args, Files::Filesystem& fs ) const
9594 {
96- X_Download::perform_and_exit (args, paths );
95+ X_Download::perform_and_exit (args, fs );
9796 }
9897}
0 commit comments