@@ -1335,12 +1335,12 @@ namespace
13351335 ExpectedL<Unit> publish (const AzureUpkgSource& src,
13361336 StringView package_name,
13371337 StringView package_version,
1338- const Path& package_dir ,
1338+ const Path& zip_path ,
13391339 StringView description,
13401340 MessageSink& sink) const
13411341 {
13421342 Command cmd = base_cmd (src, package_name, package_version, " publish" );
1343- cmd.string_arg (" --description" ).string_arg (description).string_arg (" --path" ).string_arg (package_dir );
1343+ cmd.string_arg (" --description" ).string_arg (description).string_arg (" --path" ).string_arg (zip_path );
13441344 return run_az_artifacts_cmd (cmd, sink);
13451345 }
13461346
@@ -1383,10 +1383,12 @@ namespace
13831383 size_t count_stored = 0 ;
13841384 auto ref = make_feedref (request, " " );
13851385 std::string package_description = " Cached package for " + ref.id ;
1386+
1387+ const Path& zip_path = request.zip_path .value_or_exit (VCPKG_LINE_INFO);
13861388 for (auto && write_src : m_sources)
13871389 {
1388- auto res = m_azure_tool. publish (
1389- write_src, ref.id , ref.version , request. package_dir , package_description, msg_sink);
1390+ auto res =
1391+ m_azure_tool. publish ( write_src, ref.id , ref.version , zip_path , package_description, msg_sink);
13901392 if (res)
13911393 {
13921394 count_stored++;
@@ -1401,17 +1403,26 @@ namespace
14011403 }
14021404
14031405 bool needs_nuspec_data () const override { return false ; }
1404- bool needs_zip_file () const override { return false ; }
1406+ bool needs_zip_file () const override { return true ; }
14051407
14061408 private:
14071409 AzureUpkgTool m_azure_tool;
14081410 std::vector<AzureUpkgSource> m_sources;
14091411 };
14101412
1411- struct AzureUpkgGetBinaryProvider : public IReadBinaryProvider
1413+ struct AzureUpkgGetBinaryProvider : public ZipReadBinaryProvider
14121414 {
1413- AzureUpkgGetBinaryProvider (const ToolCache& cache, MessageSink& sink, AzureUpkgSource source)
1414- : m_azure_tool(cache, sink), m_sink(sink), m_source(source)
1415+ AzureUpkgGetBinaryProvider (ZipTool zip,
1416+ const Filesystem& fs,
1417+ const ToolCache& cache,
1418+ MessageSink& sink,
1419+ const AzureUpkgSource& source,
1420+ const Path& buildtrees)
1421+ : ZipReadBinaryProvider(std::move(zip), fs)
1422+ , m_azure_tool(cache, sink)
1423+ , m_sink(sink)
1424+ , m_source(std::move(source))
1425+ , m_buildtrees(buildtrees)
14151426 {
14161427 }
14171428
@@ -1424,21 +1435,32 @@ namespace
14241435 return msg::format (msgRestoredPackagesFromAZUPKG, msg::count = count, msg::elapsed = ElapsedTime (elapsed));
14251436 }
14261437
1427- void fetch (View<const InstallPlanAction*> actions, Span<RestoreResult> out_status ) const override
1438+ void acquire_zips (View<const InstallPlanAction*> actions, Span<Optional<ZipResource>> out_zips ) const override
14281439 {
14291440 for (size_t i = 0 ; i < actions.size (); ++i)
14301441 {
1431- auto info = BinaryPackageReadInfo{ *actions[i]} ;
1432- auto ref = make_feedref (info, " " ) ;
1433- auto res = m_azure_tool. download (m_source, ref. id , ref. version , info. package_dir , m_sink );
1442+ const auto & action = *actions[i];
1443+ const auto info = BinaryPackageReadInfo{action} ;
1444+ const auto ref = make_feedref ( info, " " );
14341445
1435- if (res)
1446+ Path temp_dir = m_buildtrees / fmt::format (" upkg_download_{}" , info.package_abi );
1447+ Path temp_zip_path = temp_dir / fmt::format (" {}.zip" , ref.id );
1448+ Path final_zip_path = m_buildtrees / fmt::format (" {}.zip" , ref.id );
1449+
1450+ const auto result = m_azure_tool.download (m_source, ref.id , ref.version , temp_dir, m_sink);
1451+ if (result.has_value () && m_fs.exists (temp_zip_path, IgnoreErrors{}))
14361452 {
1437- out_status[i] = RestoreResult::restored;
1453+ m_fs.rename (temp_zip_path, final_zip_path, VCPKG_LINE_INFO);
1454+ out_zips[i].emplace (std::move (final_zip_path), RemoveWhen::always);
14381455 }
14391456 else
14401457 {
1441- out_status[i] = RestoreResult::unavailable;
1458+ msg::println_warning (result.error ());
1459+ }
1460+
1461+ if (m_fs.exists (temp_dir, IgnoreErrors{}))
1462+ {
1463+ m_fs.remove (temp_dir, VCPKG_LINE_INFO);
14421464 }
14431465 }
14441466 }
@@ -1447,6 +1469,7 @@ namespace
14471469 AzureUpkgTool m_azure_tool;
14481470 MessageSink& m_sink;
14491471 AzureUpkgSource m_source;
1472+ const Path& m_buildtrees;
14501473 };
14511474
14521475 ExpectedL<Path> default_cache_path_impl ()
@@ -2413,7 +2436,8 @@ namespace vcpkg
24132436 }
24142437
24152438 if (!s.archives_to_read .empty () || !s.url_templates_to_get .empty () || !s.gcs_read_prefixes .empty () ||
2416- !s.aws_read_prefixes .empty () || !s.cos_read_prefixes .empty () || s.gha_read )
2439+ !s.aws_read_prefixes .empty () || !s.cos_read_prefixes .empty () || s.gha_read ||
2440+ !s.upkg_templates_to_get .empty ())
24172441 {
24182442 ZipTool zip_tool;
24192443 zip_tool.setup (tools, out_sink);
@@ -2446,13 +2470,24 @@ namespace vcpkg
24462470 std::make_unique<ObjectStorageProvider>(zip_tool, fs, buildtrees, std::move (prefix), cos_tool));
24472471 }
24482472
2473+ for (auto && src : s.upkg_templates_to_get )
2474+ {
2475+ m_config.read .push_back (std::make_unique<AzureUpkgGetBinaryProvider>(
2476+ zip_tool, fs, tools, out_sink, std::move (src), buildtrees));
2477+ }
2478+
24492479 if (s.gha_read )
24502480 {
24512481 const auto & url = *args.actions_cache_url .get ();
24522482 const auto & token = *args.actions_runtime_token .get ();
24532483 m_config.read .push_back (std::make_unique<GHABinaryProvider>(zip_tool, fs, buildtrees, url, token));
24542484 }
24552485 }
2486+ if (!s.upkg_templates_to_put .empty ())
2487+ {
2488+ m_config.write .push_back (
2489+ std::make_unique<AzureUpkgPutBinaryProvider>(tools, out_sink, std::move (s.upkg_templates_to_put )));
2490+ }
24562491 if (!s.archives_to_write .empty ())
24572492 {
24582493 m_config.write .push_back (
@@ -2502,20 +2537,6 @@ namespace vcpkg
25022537 nuget_base, std::move (s.sources_to_write ), std::move (s.configs_to_write )));
25032538 }
25042539 }
2505-
2506- if (!s.upkg_templates_to_get .empty ())
2507- {
2508- for (auto && src : s.upkg_templates_to_get )
2509- {
2510- m_config.read .push_back (
2511- std::make_unique<AzureUpkgGetBinaryProvider>(tools, out_sink, std::move (src)));
2512- }
2513- }
2514- if (!s.upkg_templates_to_put .empty ())
2515- {
2516- m_config.write .push_back (
2517- std::make_unique<AzureUpkgPutBinaryProvider>(tools, out_sink, std::move (s.upkg_templates_to_put )));
2518- }
25192540 }
25202541
25212542 m_needs_nuspec_data = Util::any_of (m_config.write , [](auto && p) { return p->needs_nuspec_data (); });
0 commit comments